Vue.prototype封装消息
main.js全局引入//封装消息提示Vue.prototype.msg = function (text) { //如果你需要让一个工具函数在每个组件可用,可以把方法挂载到 Vue.prototype上。那么组件代码里this.method() Vue.$vux.toast.show({ text: text, type: 'text'
·
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('内容')
则会自动弹出内容提示;
则会自动弹出内容提示;
更多推荐



所有评论(0)