做项目用到Vue,自定义了个组件,测试过程中报错不少,写一写报错和解决方式
1.函数带括号的问题:
报错:
[Vue warn]: Property or method "handleSaveOpinion" 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.
解决方式:
上图的函数少写了括号,加上括号即可(学习尚浅,不知道什么时候必须用括号,什么时候可以不用括号)
后续:
原来根本原因不是上面提到的错误,而是把“methods”错误的拼成了“method”
2.大小写问题:
报错:
[Vue warn]: Missing required prop: "proId"
解决方式:
既然都说了是大小写问题了,那么在组件中将大写改为小写即可(不支持驼峰命名法?)