Uncaught TypeError: Cannot read property of undefined
vue中出现这种错误
Uncaught TypeError: Cannot read property of undefined或 Uncaught TypeError: this.myMethod is not a function
导致这种错误产生的原因是在选项 property 或回调上使用箭头函数
created: () => console.log(this.a)
或 vm.$watch('a', newValue => this.myMethod())
因为箭头函数并没有 this,this 会作为变量一直向上级词法作用域查找,直至找到为止
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
