1 |
|
2 | import type { CONSTRUCTOR_OPTION } from './type'
|
3 | import getProps from './props'
|
4 | import getMethods from './methods'
|
5 | import getContainerStyle from './style'
|
6 |
|
7 | export default function (option: CONSTRUCTOR_OPTION): Function {
|
8 | const components = option.component
|
9 |
|
10 | function render (vueInstance, h, components, option) {
|
11 | if (option) {
|
12 | const { prop, method } = option
|
13 | return h(components, {
|
14 | props: getProps(vueInstance, prop),
|
15 | on: getMethods(vueInstance, method)
|
16 | })
|
17 | } else return h(components)
|
18 | }
|
19 |
|
20 | return function (h: Function) {
|
21 | const vueInstance = this
|
22 | return Array.isArray(components) ?
|
23 | h('div', getContainerStyle(option.style), components.map(({ components, option }) => render(vueInstance, h, components, option)))
|
24 | : render(vueInstance, h, components.components, components.option)
|
25 | }
|
26 | } |
\ | No newline at end of file |