美文网首页
vue $slots, $scopedSlots ,如何在r

vue $slots, $scopedSlots ,如何在r

作者: 淡然7698 | 来源:发表于2021-11-29 14:39 被阅读0次

$scopedSlots 传参

           <div>
              {this.$scopedSlots.head({
                props: headName
              })}
           </div>

注意:从 2.6.0 开始,这个 property 有两个变化:

作用域插槽函数现在保证返回一个 VNode 数组,除非在返回值无效的情况下返回 undefined。

所有的 slots 现在都会作为函数暴露在scopedSlots 中。如果你在使用渲染函数,不论当前插槽是否带有作用域,都推荐始终通过 $scopedSlots 访问它们。

vue3中移除了scopedSlots api,在 3.x 中,将所有 this.scopedSlots 替换为 this.$slots。

相关文章

网友评论

      本文标题:vue $slots, $scopedSlots ,如何在r

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