一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

vue.extend实现alert模态框弹窗组件

时间:2018-05-02 编辑:猪哥 来源:一聚教程网

本文通过Vue.extend创建组件构造器的方法写弹窗组件,供大家参考,具体内容如下

alert.js文件代码

import Vue from 'vue'
// 创建组件构造器
const alertHonor = Vue.extend(require('./alert.vue'));

var currentMsg = {callback:function(){
}}

export default function(options){

  var alertComponent = new alertHonor({el: document.createElement('div')});
  alertComponent.title = options.title;
  alertComponent.ranking = options.ranking;
  // 把alertHonor.vue加入body中
  alertComponent.$appendTo(document.body);

  // 回调函数
  alertComponent.callback = function(action) {
    if (action == 'share') {
      options.share();
    }
  };

}

alert.vue代码


 引用页面代码

热门栏目