Vue.http.interceptors.push((request,next)=>{
console.log(this) //此处打印出undefined
next(function (response) {
this.showLoading = false; //此处的this是正确的
})
})
在打印this处,我如何执行this.showLoading=true,显示正在加载?
Vue.http.interceptors.push((request,next)=>{
console.log(this) //此处打印出undefined
next(function (response) {
this.showLoading = false; //此处的this是正确的
})
})
在打印this处,我如何执行this.showLoading=true,显示正在加载?
Vue.http.interceptors.push(function(request,next){
console.log(this) //改成这样就可以了,谢谢楼上
next(function (response) {
this.showLoading = false; //此处的this是正确的
})
})
9 回答1.7k 阅读✓ 已解决
6 回答1k 阅读
3 回答1.4k 阅读✓ 已解决
4 回答991 阅读✓ 已解决
2 回答1.2k 阅读✓ 已解决
3 回答895 阅读
3 回答1.3k 阅读✓ 已解决
不要用箭头函数!