国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

vue.extend實現(xiàn)alert模態(tài)框彈窗組件

2024-05-06 15:34:46
字體:
供稿:網(wǎng)友

本文通過Vue.extend創(chuàng)建組件構(gòu)造器的方法寫彈窗組件,供大家參考,具體內(nèi)容如下

alert.js文件代碼

import Vue from 'vue'// 創(chuàng)建組件構(gòu)造器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;  // 把a(bǔ)lertHonor.vue加入body中  alertComponent.$appendTo(document.body);  // 回調(diào)函數(shù)  alertComponent.callback = function(action) {    if (action == 'share') {      options.share();    }  };}

alert.vue代碼

<template>  <div class="alertHonor" v-if="showAlertHonor">    <div class="alertHonorBox" @click="alertHonorClick"></div>    <div class="honorWindow">      <div class="honorClose" @click="honorClose"></div>      <div class="honorBg">        <div class="honorShare">          <div class="honorBgLeft">升級通知</div>          <div class="honorBgRight" @click='handleActions("share")'>分享</div>        </div>        <div class="honorText">{{title}}</div>      </div>      <div class="honorRanking">        {{ranking}}      </div>    </div>  </div></template><script>  export default{    props:{      img:{type:String},  //圖片      title:{type:String},  //達(dá)人昵稱      ranking:{type:String},   //排名      share:{type:Function}, //分享    },    data(){      return{        showAlertHonor:true      }    },    methods:{      alertHonorClick(){ //點擊其他區(qū)域        this.showAlertHonor = false; //關(guān)閉整個窗口      },      honorClose(){ //點擊關(guān)閉圖標(biāo)        this.showAlertHonor = false;      },      handleActions(action){        this.callback(action);      }    }  }</script>

 引用頁面代碼

<script>  import AlertHonor from '../alert.js'  export default{    data(){      return{        title:'我的榮譽(yù)'      }    },    ready(){    },    methods:{      back(){        alert(1)      },      submit(){        var vm = this;        AlertHonor({                    title:'拜訪達(dá)人',          ranking:'您在全國排名第99',          share: function(){            vm.share();          }        });      },      share(){ //點擊分享        alert('分享');      },    }  }</script>

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持錯新站長站。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 清镇市| 建湖县| 张家口市| 西昌市| 湛江市| 鲜城| 偏关县| 那坡县| 偃师市| 桐庐县| 通城县| 安乡县| 东安县| 五大连池市| 区。| 新乡县| 郎溪县| 邢台市| 蓝田县| 平凉市| 平罗县| 盐山县| 平潭县| 新蔡县| 禹州市| 长乐市| 温州市| 鄂托克前旗| 长沙市| 鹤峰县| 金坛市| 晋州市| 阿坝县| 彝良县| 泸溪县| 嘉祥县| 瑞安市| 乌拉特前旗| 剑川县| 白水县| 麻城市|