欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue彈窗組件使用方法

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

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

彈窗是一個項目必備的復(fù)用利器,所以封裝起來,保證項目ui一致,是很有必要的。學(xué)了一段時間vue,想想還是用vue寫一下吧。用的很小白,但是會寫出來了,說明我也有進(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="點擊我,呼喚彈窗,再來一遍" v-if="isHide" @click="isHide=!isHide">
    <ys-modal-component 
       v-if="!isHide"
       modal-title="溫馨提示" 
       ok-btn="確認(rèn)購買" 
       cancel-btn="去意已決"
       @on-ok="ok"
       @on-cancel="cancel"
     >
      <div slot="modal-content">
        尊敬的用戶,您購買的商品將于支付成功后3-7個工作日內(nèi)發(fā)貨,敬請周知。祝您購物愉快!
      </div>
    </ys-modal-component>
  </div>
  <script>
    /*
      props:
        modalTitle: 彈窗標(biāo)題
        okBtn: 確認(rèn)按鈕
        cancelBtn: 取消按鈕
        注意事項:傳參時候使用烤串的書寫方式xx-xxx
      slot:
        modal-content: 內(nèi)容區(qū)域
        modal-footer: 頁腳按鈕區(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("點擊確定");
          this.$emit("on-ok"); 
        },
        cancelHandle () {
          console.log("點擊取消");
          this.$emit("on-cancel");
        }
      }
    })


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

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

相關(guān)文章

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

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

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

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

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

    vue使用less報錯:Inline JavaScript is not ena

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

    公共Hooks封裝文件下載useDownloadFile實例詳解

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

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

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

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

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

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

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

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

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

    vue-cli+webpack在生成的項目中使用bootstrap實例代碼

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

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

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

最新評論