in the ts file, it is supposed to intercept the error, and then pop up a message, but calling this here will report an error.
//
axiosTokenInstance.interceptors.response.use((response: any) => {
if (response.data.statusCode !== 0) {
this.$Message.error("haha");
} else {
return response.data;
}
},
(error) => {
if (error.response) {
const { message } = error.response.data;
return Promise.reject(new Error(message));
}
return Promise.reject(error);
}
);
then modified the code
const that = this;
//
axiosTokenInstance.interceptors.response.use((response: any) => {
if (response.data.statusCode !== 0) {
that.$Message.error("haha");
} else {
return response.data;
}
},
(error) => {
if (error.response) {
const { message } = error.response.data;
return Promise.reject(new Error(message));
}
return Promise.reject(error);
}
);
After the modification, the outer this is marked red again [ts] "this" implicitly has the type "any" because it has no type comments. [2683] who can tell us how to solve the problem? /