最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

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

来源:动视网 责编:小OO 时间:2020-11-27 19:35:00
文档

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

本文通过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(';p';)});alertComponent.title = options.title。
推荐度:
导读本文通过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(';p';)});alertComponent.title = options.title。


这篇文章主要为大家详细介绍了vue.extend实现alert模态框弹窗组件,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

本文通过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('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 class="alertHonor" v-if="showAlertHonor">
 <p class="alertHonorBox" @click="alertHonorClick"></p>
 <p class="honorWindow">
 <p class="honorClose" @click="honorClose"></p>
 <p class="honorBg">
 <p class="honorShare">
 <p class="honorBgLeft">升级通知</p>
 <p class="honorBgRight" @click='handleActions("share")'>分享</p>
 </p>
 <p class="honorText">{{title}}</p>
 </p>
 <p class="honorRanking">
 {{ranking}}
 </p>
 </p>
 </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>

文档

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

本文通过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(';p';)});alertComponent.title = options.title。
推荐度:
标签: VUE 实现 组件
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top