这次给大家带来vue.extend实现alert模态框弹窗步骤详解,vue.extend实现alert模态框弹窗的注意事项有哪些,下面就是实战案例,一起来看一下。
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('p')});
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代码
<template>
<p>
</p>
<p></p>
<p>
</p>
<p></p>
<p>
</p>
<p>
</p>
<p>升级通知</p>
<p>分享</p>
<p>{{title}}</p><div class="aritcle_card flexRow artxards">
<div class="artcardd flexRow">
<a class="aritcle_card_img" rel="nofollow" href="/xiazai/js/6223" title="多步骤表单内容提交ui特效"><img
src="https://img.php.cn/upload/jscode/000/287/557/6019f8bc8e84d734.png" alt="多步骤表单内容提交ui特效" onerror="this.onerror='';this.src='/static/lhimages/moren/morentu.png'" ></a>
<div class="aritcle_card_info flexColumn">
<a rel="nofollow" href="/xiazai/js/6223" title="多步骤表单内容提交ui特效" class="overflowclass">多步骤表单内容提交ui特效</a>
<p class="overflowclass">jQuery_css3三个步骤表单内容填写提交,邮箱密码设置,个人信息填写,社交联系方式等表单提交代码。</p>
</div>
<a rel="nofollow" href="/xiazai/js/6223" title="多步骤表单内容提交ui特效" class="aritcle_card_btn flexRow flexcenter"><b></b><span>下载</span>
</a>
</div>
</div>
<p>
{{ranking}}
</p>
</template><script>
export default{
props:{
img:{type:String}, //图片
title:{type:String}, //达人昵称
ranking:{type:String}, //排名
share:{type:Function}, //分享
},
data(){
return{
showAlertHonor:true
}
},
methods:{
alertHonorClick(){ //点击其他区域
this.showAlertHonor = false; //关闭整个窗口
},
honorClose(){ //点击关闭图标
this.showAlertHonor = false;
},
handleActions(action){
this.callback(action);
}
}
}
</script>
引用页面代码
<script>
import AlertHonor from '../alert.js'
export default{
data(){
return{
title:'我的荣誉'
}
},
ready(){
},
methods:{
back(){
alert(1)
},
submit(){
var vm = this;
AlertHonor({
title:'拜访达人',
ranking:'您在全国排名第99',
share: function(){
vm.share();
}
});
},
share(){ //点击分享
alert('分享');
},
}
}
</script>
相信看了本文案例你已经掌握了方法,更多精彩请关注php中文网其它相关文章!
推荐阅读:
前端入门到VUE实战笔记:立即使用
在学习笔记中,你将探索 前端 的入门与实战技巧!










