vue.extend中怎么實(shí)現(xiàn)一個alert模態(tài)框彈窗組件

這篇文章將為大家詳細(xì)講解有關(guān)vue.extend中怎么實(shí)現(xiàn)一個alert模態(tài)框彈窗組件,文章內(nèi)容質(zhì)量較高,因此小編分享給大家做個參考,希望大家閱讀完這篇文章后對相關(guān)知識有一定的了解。

創(chuàng)新互聯(lián)建站專業(yè)為企業(yè)提供遂川網(wǎng)站建設(shè)、遂川做網(wǎng)站、遂川網(wǎng)站設(shè)計、遂川網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計與制作、遂川企業(yè)網(wǎng)站模板建站服務(wù),10多年遂川做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價值的思路和整體網(wǎng)絡(luò)服務(wù)。

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(){ //點(diǎn)擊其他區(qū)域
        this.showAlertHonor = false; //關(guān)閉整個窗口
      },
      honorClose(){ //點(diǎn)擊關(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(){ //點(diǎn)擊分享
        alert('分享');
      },
    }
  }
</script>

關(guān)于vue.extend中怎么實(shí)現(xiàn)一個alert模態(tài)框彈窗組件就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。

網(wǎng)站欄目:vue.extend中怎么實(shí)現(xiàn)一個alert模態(tài)框彈窗組件
文章轉(zhuǎn)載:http://bm7419.com/article34/gocppe.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供電子商務(wù)標(biāo)簽優(yōu)化、虛擬主機(jī)、營銷型網(wǎng)站建設(shè)、網(wǎng)站策劃定制開發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁設(shè)計公司