美文网首页
Vue render 函数

Vue render 函数

作者: 王小妞闯天涯 | 来源:发表于2024-03-04 13:52 被阅读0次

functional: true,
props: {}, // 暂时没有需求需要,随着需求扩展可以在此定义通过html分割
render: (h, context) => {
const { children, slots } = context
const defaultSlot = slots.default ? slots.default() : []
const vNode = []
const validNode = children.filter((a) => a.tag !== undefined && a.tag !== null)
if (validNode.length > 0) {
for (let index = 0; index < validNode.length; index++) {
const ele = validNode[index]
vNode.push(ele)
if (index < validNode.length - 1) {
vNode.push(h('span', { class: ['sh_divide'] }))
}
}
}
vNode.push(...defaultSlot)
const container = h('div', { class: ['sh_space'] }, vNode)
return container

相关文章

网友评论

      本文标题:Vue render 函数

      本文链接:https://www.haomeiwen.com/subject/aatrzdtx.html