vue [Vue warn]: Property or method "xxxx" 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.
详细描述
data中获取元素某个属性时报错roperty or method "xxxx" 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.
版本信息
Vue2.0
复现过程
此报错产生的原因很多,主要原因是使用了未知属性或方法。
解决方案
在浏览器解释html语言时,会将属性转换成小写,所以vue中使用大写驼峰的属性无法被html部分绑定。
另外在vue官方文档中也有相关说明
“动态参数表达式有一些语法约束,在 DOM 中使用模板时你需要回避大写键名。”
因此,修改html模板中的属性名称以及js对象值为小写即可

文章有用
已有
0人
推荐该文章,推荐越多越容易获得的官方扶持