How to use toast in api.js files in vue framework

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

clipboard.png

clipboard.png

  • import {Toast} from "vux" console.log(Toast) :

clipboard.png

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.

Mar.14,2022

introduce

into api.js
import { Toast } from 'vux'

after

Toast.show({
    text: 'hello billo...'
})
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1be9b00-31990.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1be9b00-31990.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?