不要在选项属性或回调上使用箭头函数,比如
created: () => console.log(this.a)或vm.$watch('a', newValue => this.myMethod())。因为箭头函数并没有this,this会作为变量一直向上级词法作用域查找,直至找到为止,经常导致Uncaught TypeError: Cannot read property of undefined或Uncaught TypeError: this.myMethod is not a function之类的错误。
错误示范:
1  | <el-button type="primay" icon="el-icon-plus" @click="add"></el-button>  | 
正确示范:
1  | <script>  | 
