刚学习js 问个很幼稚的问题,在axios.().then回调中访问不到 vue组件实例
发布于 4 年前 作者 mettmac 4384 次浏览 最后一次编辑是 4 年前 来自 问答
粉丝福利 : 关注VUE中文社区公众号,回复视频领取粉丝福利

代码如下图: getAllGoods() 和 getAllGood_Test() 方法 axios.then回调写法: 1:匿名函数回调 提示异常: 返回结果异常:TypeError: Cannot read property ‘goods’ of undefined ,看了一下 this 是 undefined 2: 箭头函数回调 正常 然后我百度了一下是匿名回调函数this指向的问题。 我在chrome开发工具验证了一下匿名回调函数内 this是指向window,但是我这里this却是 undefined why? 1.png

回到顶部