cancel(){
const CancelToken = axios.CancelToken;
let cancel;
axios.defaults.baseURL = process.env.NODE_ENV === 'production' ? process.env.VUE_APP_TARGET : '/api'
axios.get('/er/track', {
params: {
deviceId: this.id,
startTime: this.startTime,
endTime: this.endTime,
},
cancelToken: new CancelToken(function executor(c) {
// executor 函数接收一个 cancel 函数作为参数
cancel = c;
})
}).catch(res=>{
})
cancel();
}
//在需要中断请求接口时调用cancel函数方法