赞
踩
今天在修改老项目的过程中发现了一个警告:
[Vue warn]: Property or method "scope" 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.
slot-scope="scope"
这样的写法是用在 Vue.js 2.5 版本及更早的版本
中,用于处理组件的插槽(slot)。
而 v-slot="scope"
这样的写法是从 Vue.js 2.6.0 版本开始引入的新语法
,用于简化处理作用域插槽(scoped slot)。这个新的写法让代码更加简洁易读,是推荐在 Vue.js 2.6.0 及之后的版本中使用的方式。
但项目中的vue版本是2.5.16,但代码中用到了高版本才支持的v-slot
,导致报此警告。
将v-slot=“scope” 换成slot-scope=“scope”
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。