现象
在created和mounted,使用this调用XX方法,运行的时候报错
mounted TypeError: this.XX is not a function
created TypeError: this.XX is not a function
解决方法
定义self变量为this,使用self去调用方法就可以了
const self = this;
// XXX为方法名
self.XXX();
在created和mounted,使用this调用XX方法,运行的时候报错
mounted TypeError: this.XX is not a function
created TypeError: this.XX is not a function
定义self变量为this,使用self去调用方法就可以了
const self = this;
// XXX为方法名
self.XXX();