vue项目中出现Property or method "$attrs" is not defined on the instance but referenced during render. M

****1、项目中出现Property or method " a t t r s " i s n o t d e f i n e d o n t h e i n s t a n c e b u t r e f e r e n c e d d u r i n g r e n d e r . M a k e s u r e t o d e c l a r e r e a c t i v e d a t a p r o p e r t i e s i n t h e d a t a o p t i o n . ( attrs" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option.**** (属性或方法“ attrs”未在实例上定义,但在呈现期间被引用。确保在data选项中声明反应性数据属性)
what? 看到这个问题真的是一脸懵逼。查询了好久才找到问题的所在并解决
问题原因:vue版本与vue-template-compiler版本不兼容导致的
解决办法:我当时写项目vue是2.6.10 所以把vue-template-compiler也升级到2.6.10解决的问题( $attrs is readonly的问题同样适用)
npm i vue-template-compiler@当前的版本号 --save重新安装

发布了3 篇原创文章 · 获赞 0 · 访问量 15

猜你喜欢

转载自blog.csdn.net/xsx821/article/details/105426717