'$message' of undefined解决办法
2019-11-07 本文已影响0人
小睿同学
有的时候,会出现这样的小问题:
TypeError: Cannot read property '$message' of undefined,
困扰了很久,最近才明白
原因:this的指向问题
this始终指向Vue,所以需要将this保存在that中,在使用其他操作的时候可以用that代替。
var that = this;
完美de解决问题。。。
有的时候,会出现这样的小问题:
TypeError: Cannot read property '$message' of undefined,
困扰了很久,最近才明白
this始终指向Vue,所以需要将this保存在that中,在使用其他操作的时候可以用that代替。
var that = this;
完美de解决问题。。。