我在一个页面中执行api ajax调用,catch异常时,用element ui提供的$message函数打印错误提示,当ajax调用正在进行中时,点击侧边栏导航菜单切换到其它页面(router-link变了),然后在新的页面上弹出了ajax调用超时的错误提示,既然已经离开了,能不能让它不要显示了?
apiListProjects(platform_id, 0)
.then(response => {
if (response.data.platform_id === this.platformId.toString()) {
this.projectList = response.data.projects
this.currentPlatformLoadingFromParent.bol = false
}
})
.catch((err) => {
this.currentPlatformLoadingFromParent.bol = false
if (err.response) {
this.$message({
type: 'error',
message: '获取项目列表失败,错误码:' + err.response.status,
})
} else {
this.$message({
type: 'error',
message: '获取项目列表失败,后端没有响应!',
})
}
})
用的是axios吗