简单记录一下,Vue3.0作用域插槽报错问题。

上班之后,一直没时间写博客了,很多东西解决后,很容易忘了,今天简单记录一下。

最近看 Vue3.0 插槽变了。想试验一下,结果本地编辑器上 匿名插槽,和具名插槽 按照案例 写都没问题,

就是 作用域 插槽,怎么写都报错。一直提示 未定义之类的。如下:

roperty or method "slotProps" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.
<!--
属性或方法“slotProps”不是在实例上定义的,而是在渲染期间引用的。 通过初始化该属性,确保该属性是反应性的,无论是在数据选项中,还是在基于类的组件中。  
-->

想半天也,想不到 是哪里写错了。

最后才反应过了,这些插槽是 Vue 2.6以后就改了。我本地的Vue版本 还是2.0了。肯定不支持。

换了官方一个 新的 Vue CDN 解决!

<script src="https://cdn.jsdelivr.net/npm/vue@2.6.12"></script>
不要和别人比,要赢得是自己。(ง •̀_•́)ง
原文地址:https://www.cnblogs.com/byx1024/p/14842192.html