Vue.prototype封装消息

来源:互联网 发布:淘宝上发光闹钟说明书 编辑:程序博客网 时间:2024/06/01 08:30
import  {ToastPlugin} from 'vux'  全局引入这个组件

main.js全局引入
//封装消息提示
Vue.prototype.msg = function (text) { //如果你需要让一个工具函数在每个组件可用,可以把方法挂载到 Vue.prototype上。那么组件代码里this.method()
    Vue.$vux.toast.show({
        text: text,
        type: 'text'
    })
}
然后在其他vue文本里用this.msg('内容')
则会自动弹出内容提示;
原创粉丝点击