mirror of
https://github.com/certd/certd.git
synced 2026-07-12 16:27:34 +08:00
33 lines
650 B
Vue
33 lines
650 B
Vue
|
|
<script>
|
||
|
|
import { h, resolveComponent } from 'vue'
|
||
|
|
import _ from 'lodash-es'
|
||
|
|
export default {
|
||
|
|
name: 'component-render',
|
||
|
|
props: {
|
||
|
|
name: {
|
||
|
|
type: String,
|
||
|
|
default: 'a-input'
|
||
|
|
},
|
||
|
|
children: {
|
||
|
|
type: Array
|
||
|
|
},
|
||
|
|
on: {
|
||
|
|
type: Object
|
||
|
|
}
|
||
|
|
},
|
||
|
|
setup (props, context) {
|
||
|
|
const attrs = {
|
||
|
|
...context.$attrs
|
||
|
|
}
|
||
|
|
_.forEach(props.on, (value, key) => {
|
||
|
|
attrs[key] = value
|
||
|
|
if (typeof value === 'string') {
|
||
|
|
// eslint-disable-next-line no-eval
|
||
|
|
attrs[key] = eval(value)
|
||
|
|
}
|
||
|
|
})
|
||
|
|
return () => h(resolveComponent(props.name), context.$attrs, props.children)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
</script>
|