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

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

alert.js文件代码

rush: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代码

<div class="jb51code">
<pre class="brush:xhtml;">

引用页面代码

rush:xhtml;">

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程之家。

相关文章

可以通过min-width属性来设置el-table-column的最小宽度。以...
yarn dev,当文件变动后,会自动重启。 yanr start不会自动重...
ref 用于创建一个对值的响应式引用。这个值可以是原始值(如...
通过修改 getWK005 函数来实现这一点。这里的 query 参数就是...
&lt;el-form-item label=&quot;入库类型&quot; ...
API 变动 样式类名变化: 一些组件的样式类名有所变动,可能需...