vue项目 想实现验证码错误后自动发起请求到后端刷新验证码 ,在login.vue中有个getCaptcha()方法,同时我对vue中axios.js做了全局结果拦截 所以返回结果到了axios.js 现在想在axios.js 调用login.vue中有个getCaptcha()方法刷新验证码 请问怎么实现?
代码块
getCaptcha() {
// 发送axios请求
this.$axios.get("/captcha").then((res) => {
console.log(res);
this.loginForm.token = res.data.data.token;
this.captchaImg = res.data.data.captchaImg;
this.loginForm.code = "";
});
request.interceptors.response.use(response => {
let res = response.data;
console.log("response")
console.log(res)
if(res.msg=='验证码错误'){
//具体的验证码处理
}
)}