美文网首页
'$message' of undefined解决办法

'$message' of undefined解决办法

作者: 小睿同学 | 来源:发表于2019-11-07 11:40 被阅读0次

有的时候,会出现这样的小问题:
TypeError: Cannot read property '$message' of undefined,
困扰了很久,最近才明白

原因:this的指向问题

this始终指向Vue,所以需要将this保存在that中,在使用其他操作的时候可以用that代替。

var that = this;

完美de解决问题。。。

相关文章

网友评论

      本文标题:'$message' of undefined解决办法

      本文链接:https://www.haomeiwen.com/subject/iitqbctx.html