亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

vue彈窗組件使用方法

 更新時(shí)間:2018年04月28日 10:56:28   作者:章魚(yú)no丸子  
彈窗是一個(gè)項(xiàng)目必備的復(fù)用利器,這篇文章主要介紹了vue彈窗組件的使用方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了vue彈窗組件的具體代碼,供大家參考,具體內(nèi)容如下

彈窗是一個(gè)項(xiàng)目必備的復(fù)用利器,所以封裝起來(lái),保證項(xiàng)目ui一致,是很有必要的。學(xué)了一段時(shí)間vue,想想還是用vue寫(xiě)一下吧。用的很小白,但是會(huì)寫(xiě)出來(lái)了,說(shuō)明我也有進(jìn)步一丟丟了。繼續(xù)加油….

代碼貼圖如下,樣式比較丑,不要介意…

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>ys-vue-modal-component</title>
  <style>
    p,h4{
      margin:0;
    }
    .modal{
      width: 480px;
      background-color: #fff;
      border: 1px solid rgba(0, 0, 0, .3);
      border-radius: 6px;
      box-shadow: 0 4px 12px rgba(0, 0, 0, .5);
      margin: 50px;
    }
    .modal-header {
      color: #fff;
      background: cadetblue;
      border-radius: 6px 6px 0 0;
      padding: 15px;
      border-bottom: 1px solid #5e9fa1;
    }
    .modal-content div {
      padding: 15px 10px;
    }
    .modal-footer {
      padding: 15px;
      text-align: right;
      border-top: 1px solid #e5e5e5;
    }
    .btn {
      border: 1px solid #d1d1d1;
      border-radius: 3px;
      background-color: #f7f7f7;
      background: -webkit-gradient(linear, 0 0, 0 100%, from(#f7f7f7),
     to(#f2f2f2));
      background: -moz-gradient(linear, 0 0, 0 100%, from(#f7f7f7),
     to(#f2f2f2));
      background: -o-gradient(linear, 0 0, 0 100%, from(#f7f7f7), to(#f2f2f2));
      background: -ms-gradient(linear, 0 0, 0 100%, from(#f7f7f7), to(#f2f2f2));
      height: 28px;
      padding: 0 20px;
      cursor: pointer;
      line-height: 28px;
      display: inline-block;
      color: #666666;
      margin-right: 5px;
      outline: none;
    }
    .blue {
       border: 1px solid #5e9fa1;
      background-color: #5e9fa1;
      background: -webkit-gradient(linear, 0 0, 0 100%, from(#74c4c6),
     to(#5e9fa1));
      background: -moz-gradient(linear, 0 0, 0 100%, from(#74c4c6),
     to(#5e9fa1));
      background: -o-gradient(linear, 0 0, 0 100%, from(#74c4c6), to(#5e9fa1));
      background: -ms-gradient(linear, 0 0, 0 100%, from(#74c4c6), to(#5e9fa1));
      color: #FFFFFF;
    }    
  </style>
  <script src="https://unpkg.com/vue/dist/vue.js"></script>
</head>
<body>
  <div id="app"> 
    <input type="button" class="btn blue" value="點(diǎn)擊我,呼喚彈窗,再來(lái)一遍" v-if="isHide" @click="isHide=!isHide">
    <ys-modal-component 
       v-if="!isHide"
       modal-title="溫馨提示" 
       ok-btn="確認(rèn)購(gòu)買(mǎi)" 
       cancel-btn="去意已決"
       @on-ok="ok"
       @on-cancel="cancel"
     >
      <div slot="modal-content">
        尊敬的用戶,您購(gòu)買(mǎi)的商品將于支付成功后3-7個(gè)工作日內(nèi)發(fā)貨,敬請(qǐng)周知。祝您購(gòu)物愉快!
      </div>
    </ys-modal-component>
  </div>
  <script>
    /*
      props:
        modalTitle: 彈窗標(biāo)題
        okBtn: 確認(rèn)按鈕
        cancelBtn: 取消按鈕
        注意事項(xiàng):傳參時(shí)候使用烤串的書(shū)寫(xiě)方式xx-xxx
      slot:
        modal-content: 內(nèi)容區(qū)域
        modal-footer: 頁(yè)腳按鈕區(qū)域
      methods: 
        okHandle: 觸發(fā)確認(rèn)on-ok自定義事件
        cancelHandle: 觸發(fā)取消on-cancel自定義事件
     */
    Vue.component('ys-modal-component', {
      props: {
        modalTitle: {
          type: String,
          default: '標(biāo)題區(qū)域'
        },
        okBtn: {
          type: String,
          default: '確認(rèn)'
        },
        cancelBtn: {
          type: String,
          default: '取消'
        }
      },
      template: `
        <div class="modal">
          <div class="modal-header">
            <h4>{{ modalTitle }}</h4>
          </div>
          <div class="modal-content">
            <div>
              <slot name="modal-content">內(nèi)容區(qū)域</slot>
            </div>
          </div>
          <div class="modal-footer">
              <input class="btn blue" type="button" v-model="okBtn" @click="okHandle" />
              <input class="btn" type="button" v-model="cancelBtn" @click="cancelHandle" />
          </div>
        </div>
      `,
      methods: {
        okHandle () {
          console.log("點(diǎn)擊確定");
          this.$emit("on-ok"); 
        },
        cancelHandle () {
          console.log("點(diǎn)擊取消");
          this.$emit("on-cancel");
        }
      }
    })


    new Vue({
      el: "#app",
      data: {
        isHide: false
      },
      methods: {
        ok () {
          alert("歡迎您購(gòu)買(mǎi)本產(chǎn)品");
        },
        cancel () {
          this.isHide = !this.isHide;
        }
      }
    })
  </script>
</body>
</html>

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • vue3中輕松實(shí)現(xiàn)switch功能組件的全過(guò)程

    vue3中輕松實(shí)現(xiàn)switch功能組件的全過(guò)程

    這篇文章主要給大家介紹了關(guān)于vue3中輕松實(shí)現(xiàn)switch功能組件的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2021-01-01
  • 淺談一下Vue技術(shù)棧之生命周期

    淺談一下Vue技術(shù)棧之生命周期

    這篇文章主要介紹了淺談一下Vue技術(shù)棧之生命周期,每一個(gè)vue實(shí)例從創(chuàng)建到銷(xiāo)毀的過(guò)程,就是這個(gè)vue實(shí)例的生命周期,這些過(guò)程中會(huì)伴隨著一些函數(shù)的自調(diào)用,需要的朋友可以參考下
    2023-05-05
  • vue使用less報(bào)錯(cuò):Inline JavaScript is not enabled問(wèn)題

    vue使用less報(bào)錯(cuò):Inline JavaScript is not ena

    這篇文章主要介紹了vue使用less報(bào)錯(cuò):Inline JavaScript is not enabled問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-01-01
  • 公共Hooks封裝文件下載useDownloadFile實(shí)例詳解

    公共Hooks封裝文件下載useDownloadFile實(shí)例詳解

    這篇文章主要為大家介紹了公共Hooks封裝文件下載useDownloadFile實(shí)例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-11-11
  • Vue3中嵌套路由和編程式路由的實(shí)現(xiàn)

    Vue3中嵌套路由和編程式路由的實(shí)現(xiàn)

    Vue?Router在Vue.js的核心庫(kù)上提供了路由的功能,使得我們可以在單頁(yè)應(yīng)用中實(shí)現(xiàn)頁(yè)面的切換、跳轉(zhuǎn)和參數(shù)傳遞等功能,本文主要介紹了Vue3中嵌套路由和編程式路由的實(shí)現(xiàn),感興趣的可以了解一下
    2023-12-12
  • 在pycharm中開(kāi)發(fā)vue的方法步驟

    在pycharm中開(kāi)發(fā)vue的方法步驟

    這篇文章主要介紹了在pycharm中開(kāi)發(fā)vue的方法步驟,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2020-03-03
  • vue多語(yǔ)言轉(zhuǎn)換的幾種方法總結(jié)

    vue多語(yǔ)言轉(zhuǎn)換的幾種方法總結(jié)

    這篇文章主要介紹了vue多語(yǔ)言轉(zhuǎn)換的幾種方法總結(jié),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-02-02
  • 淺談Vue中插槽slot的使用方法

    淺談Vue中插槽slot的使用方法

    這篇文章主要給大家分享了 Vue中插槽slot的使用方法,下面文章內(nèi)容圍繞插槽slot的相關(guān)資料展開(kāi)其的使用方法,需要的朋友可以參考一下,希望多大家有所幫助
    2021-11-11
  • vue-cli+webpack在生成的項(xiàng)目中使用bootstrap實(shí)例代碼

    vue-cli+webpack在生成的項(xiàng)目中使用bootstrap實(shí)例代碼

    本篇文章主要介紹了vue-cli+webpack在生成的項(xiàng)目中使用bootstrap實(shí)例代碼,具有一定的參考價(jià)值,有興趣的可以了解一下
    2017-05-05
  • Vue 指令實(shí)現(xiàn)按鈕級(jí)別權(quán)限管理功能

    Vue 指令實(shí)現(xiàn)按鈕級(jí)別權(quán)限管理功能

    這篇文章主要介紹了Vue 指令實(shí)現(xiàn)按鈕級(jí)別權(quán)限管理功能,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2019-04-04

最新評(píng)論