vue中在api.js中调用vux 的toast插件

每次在调用vuxtoast插件的时候  大都是在vue项目的实例中。vue

main.jsapi

import Vue from 'vue';
import { ToastPlugin } from 'vux'
Vue.use(ToastPlugin)

Vue页面中this

 

export default {    
data () {
      return {}
},
methods: {
      goToast() {
        this.$vux.toast.show({
        type: 'text',
        position: 'middle',
        text: "消息提示!"
      })
    }
  }
}

 

但当在api.js中调用toast的写法就不是如此了。代码以下:spa

 

import Vue from 'vue';
import { ToastPlugin } from 'vux'

Vue.use(ToastPlugin)

let vm = new Vue()

vm.$vux.toast.show({
    type: 'text',
    position: 'middle',
    text: "消息提示!"
})
相关文章
相关标签/搜索