UNPKG

hg-sid

Version:

a front-end simple framework with mvc

23 lines (21 loc) 703 B
import DD from '../data-dirver' import { h } from '../virtual-dom' export default function getVTmpNode (parent, tag, properties, ...children) { // 如果 tag 是自定义的标签,例如 <Title></Title>, 返回的结果中会添加 parent、_constructor 属性 if (typeof tag === 'function' || typeof tag === 'object') { let node = new h() node.tagName = `component-${tag.cid}` node.properties = properties node.children = children // 记录父组件 node.parent = parent if (typeof tag === 'function') { node._constructor = tag } else { node._constructor = DD.extend(tag) } return node } else { return h(tag, properties, children) } }