首页 > vue-resource 使用interceptors的问题

vue-resource 使用interceptors的问题

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是正确的
    })
})
【热门文章】
【热门文章】