Vue.js学习错误记录(一)

    科技2023-10-04  77

    @TOCVue.js学习记录(一)

    Vue.js学习错误记录(一)

    组件开发

    1.错误提示: Uncaught SyntaxError: Invalid shorthand property initializer (无效的速记属性初始值设定项) 出错原因:将“:”写成了“=” el=’#app’(错误) el:’#app’,(正确)

    2.错误提示: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop’s value. Prop being mutated: “number1” 出错原因:一旦在props定义了属性,属性需要通过父组件修改

    3.错误提示: vue2.6.12.js:634 [Vue warn]: Invalid prop: type check failed for prop “number1”. Expected Number with value 12, got String with value “12”. 出错原因:类型转换问题,number1应该为Number类型,但是标签传入的值默认是String类型,需要进行类型转换,使用parseInt()/parseFloat()转换为Number类型。

    Processed: 0.025, SQL: 8