problem description
- vux for ui framework
- main.js introduces toast
import {Toast ,ToastPlugin} from "vux"
Vue.use(ToastPlugin, {position: "middle"})
- api.js uses toast
import axios from "axios";
axios.interceptors.response.use(data=> {
return data;
}, err=> {
// console.log(err.response);
if(err.response !== undefined && err.response.status == 400){
console.log(err.response);
// Message.error({message: err.response.message});
console.log(this);
this.$vux.toast.show({
text: "hello billo..."
})
if(err.response.data.message === ""){
sessionStorage.removeItem("user");
this.$router.push({ path: "/webchat" });
}
}
return Promise.reject(err);
})
- toast is undefined of the error this.$vux
- File structure
src
api
api.js
index.js
main.js
the environmental background of the problems and what methods you have tried
- introduce Toast module directly into api.js
import {Toast} from "vux"
prompt module not find.
- error screenshot
- import {Toast} from "vux" console.log(Toast) :
ask me how to handle it so that vux"s Toast can be used normally in the anonymous function of api.js "s axios.interceptors.response.use.