当前位置:   article > 正文

【Vue】Property or method “scope“ is not defined on the instance but referenced during render. Make su_property or method "scope" is not defined on the i

property or method "scope" is not defined on the instance but referenced dur

问题描述

今天在修改老项目的过程中发现了一个警告:

[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”

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/315818
推荐阅读
相关标签
  

闽ICP备14008679号