This in Axios configuration file is undefined?

problem description

found that this attribute is not found in this.$router, then check that this is undefined

related codes

/ / Please paste the code text below (do not replace the code with pictures)
import axios from "axios"
import {Loading, Message} from" element-ui"
import Debounce from "lodash/debounce"

const Axios = axios.create ({

)
baseURL:"/",
timeout:"10000",
responseType:"json",
withCredentials:true,
headers:{
    "Content-Type":"application/json; charset=UTF-8"
}

});
let needLoadingRequestCount = 0;
let loadingObj;

Axios.interceptors.request.use (

)
config=>{
    console.log(this);
    if(config.showLoading){
        showFullScreenLoading();
    }
    return config;
},
error=>{
    if(needLoadingRequestCount !== 0){
        loadingObj.close();
    }
    Message({
        showClose:true,
        message:"",
        type:"error"
    });
    return Promise.reject(error);
}

);

Axios.interceptors.response.use (

)
res =>{
    // console.log(this);
    if(res.config.showLoading){
        tryHideFullScreenLoading();
    }
    if(res.data.code !== 200 && res.data.message){
        Message({
            showClose:false,
            type:"error",
            center:true,
            message:res.data.message ? res.data.message : "! "
        });
        if(res.data.code === 9999100){
            this.$router.push("/login");
        }
        return Promise.reject(res.data.message);
    }
    return res;
},
error =>{
    if(needLoadingRequestCount !== 0){
        loadingObj.close();
    }
    Message({
        showClose:true,
        message:"",
        type:"error"
    });
    return Promise.reject(error);
}

);

function showFullScreenLoading () {

if(needLoadingRequestCount === 0){
    loadingObj = Loading.service({
                    lock:true,
                    text:"Loading",
                    spinner: "el-icon-loading",
                    background: "rgba(0, 0, 0, 0.7)"
                });
}
needLoadingRequestCount PP

}
function tryHideFullScreenLoading () {

if(needLoadingRequestCount <= 0) return
    needLoadingRequestCount --
if(needLoadingRequestCount === 0){
    Debounce(tryCloseLoading,300)();
}

}
function tryCloseLoading () {

if(needLoadingRequestCount === 0){
    loadingObj.close();
}

}
export default {

header(token){
    Axios.defaults.headers.common["Authorization"] = `ticket ${token}`;
},
post:(url,data,config = {showLoading : true}) => Axios.post(url,data,config),
get:(url,config = {showLoading : true}) => Axios.get(url,config),
delete:(url,config = {showLoading : true}) => Axios.delete(url,config)

}

what result do you expect? What is the error message actually seen?

they are all arrow functions. How could this be lost


Vue instance hasn't generated b yet,
import Vue from 'vue'
Vue.$router
or
import router from'. / router.js' (route path)
then router.push.


Hello, landlord! The current this has been changed and is no longer an object instantiated by vue. So you can mount it under window when initializing the instance object in main.js.


VueDOMthisVueDOM<br>router

import router from "../router";
// 
router.push({
   path: "xxx"
});
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1be2a9d-399c2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1be2a9d-399c2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?