//获取列表数据
getList(){
let that = this;
let formData = new FormData();
formData.append("identity_num", this.id_card);
formData.append("court_code", this.court_code);
getCasesByIdentityNum(formData,{
cancelToken:new axios.CancelToken(function(c) {
that.cancelToken.push(c)
})
}).then((res)=>{
console.log(res);
if(res.code == 200){
this.list = res.data.list;
this.list1 = this.list.slice(0,3)
this.total = res.data.total;
}
})
},
},
created() {
this.getList();
},
beforeRouteLeave(to,from,next){
console.log(this.cancelToken)
try {
this.cancelToken.forEach((cancel)=>{
cancel && cancel('取消!!!!!!!!!!');
})
}catch (e) {
console.log(e)
}
next();
}
以上为页面代码
export const getCasesByIdentityNum = function (data,config) {
//根据身份证查询案件详情
return fetch({
url: '/CaseSearch/get_cases_by_identity_num',
method: 'POST',
data,
...config
})
}
以上为axios配置