美文网首页
Vue 定义公共方法

Vue 定义公共方法

作者: 忘记_3a6a | 来源:发表于2020-05-09 10:15 被阅读0次
  • 定义的公共方法

export default {
    install(Vue) {
        Vue.prototype.showErrMeg = function (msg) {
            this.$message({
                showClose: true,
                message: msg,
                type: 'error'
            });
        };
        Vue.prototype.showSuccessMeg = function (msg) {
            this.$message({
                showClose: true,
                message: msg,
                type: 'success'
            });
        };
    }
}

  • 调用示例:this.showErrMeg(xxx)
  • main.js引入
import comFun from './comfun/index';
Vue.use(comFun);

相关文章

网友评论

      本文标题:Vue 定义公共方法

      本文链接:https://www.haomeiwen.com/subject/lzphnhtx.html