最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Element Dialog對話框的使用示例

 更新時間:2020年07月26日 14:29:03   作者:ForeverJPB.  
這篇文章主要介紹了Element Dialog對話框的使用示例,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

組件— 對話框

基本用法


<el-button type="text" @click="dialogVisible = true">點擊打開 Dialog</el-button>

<el-dialog
 title="提示"
 :visible.sync="dialogVisible"
 width="30%"
 :before-close="handleClose">
 <span>這是一段信息</span>
 <span slot="footer" class="dialog-footer">
  <el-button @click="dialogVisible = false">取 消</el-button>
  <el-button type="primary" @click="dialogVisible = false">確 定</el-button>
 </span>
</el-dialog>

<script>
 export default {
  data() {
   return {
    dialogVisible: false
   };
  },
  methods: {
   handleClose(done) {
    this.$confirm('確認(rèn)關(guān)閉?')
     .then(_ => {
      done();
     })
     .catch(_ => {});
   }
  }
 };
</script>

自定義內(nèi)容



<!-- Table -->
<el-button type="text" @click="dialogTableVisible = true">打開嵌套表格的 Dialog</el-button>

<el-dialog title="收貨地址" :visible.sync="dialogTableVisible">
 <el-table :data="gridData">
  <el-table-column property="date" label="日期" width="150"></el-table-column>
  <el-table-column property="name" label="姓名" width="200"></el-table-column>
  <el-table-column property="address" label="地址"></el-table-column>
 </el-table>
</el-dialog>

<!-- Form -->
<el-button type="text" @click="dialogFormVisible = true">打開嵌套表單的 Dialog</el-button>

<el-dialog title="收貨地址" :visible.sync="dialogFormVisible">
 <el-form :model="form">
  <el-form-item label="活動名稱" :label-width="formLabelWidth">
   <el-input v-model="form.name" autocomplete="off"></el-input>
  </el-form-item>
  <el-form-item label="活動區(qū)域" :label-width="formLabelWidth">
   <el-select v-model="form.region" placeholder="請選擇活動區(qū)域">
    <el-option label="區(qū)域一" value="shanghai"></el-option>
    <el-option label="區(qū)域二" value="beijing"></el-option>
   </el-select>
  </el-form-item>
 </el-form>
 <div slot="footer" class="dialog-footer">
  <el-button @click="dialogFormVisible = false">取 消</el-button>
  <el-button type="primary" @click="dialogFormVisible = false">確 定</el-button>
 </div>
</el-dialog>

<script>
 export default {
  data() {
   return {
    gridData: [{
     date: '2016-05-02',
     name: '王小虎',
     address: '上海市普陀區(qū)金沙江路 1518 弄'
    }, {
     date: '2016-05-04',
     name: '王小虎',
     address: '上海市普陀區(qū)金沙江路 1518 弄'
    }, {
     date: '2016-05-01',
     name: '王小虎',
     address: '上海市普陀區(qū)金沙江路 1518 弄'
    }, {
     date: '2016-05-03',
     name: '王小虎',
     address: '上海市普陀區(qū)金沙江路 1518 弄'
    }],
    dialogTableVisible: false,
    dialogFormVisible: false,
    form: {
     name: '',
     region: '',
     date1: '',
     date2: '',
     delivery: false,
     type: [],
     resource: '',
     desc: ''
    },
    formLabelWidth: '120px'
   };
  }
 };
</script>

嵌套的 Dialog


<template>
 <el-button type="text" @click="outerVisible = true">點擊打開外層 Dialog</el-button>
 
 <el-dialog title="外層 Dialog" :visible.sync="outerVisible">
  <el-dialog
   width="30%"
   title="內(nèi)層 Dialog"
   :visible.sync="innerVisible"
   append-to-body>
  </el-dialog>
  <div slot="footer" class="dialog-footer">
   <el-button @click="outerVisible = false">取 消</el-button>
   <el-button type="primary" @click="innerVisible = true">打開內(nèi)層 Dialog</el-button>
  </div>
 </el-dialog>
</template>

<script>
 export default {
  data() {
   return {
    outerVisible: false,
    innerVisible: false
   };
  }
 }
</script>

居中布局


<template>
 <el-button type="text" @click="outerVisible = true">點擊打開外層 Dialog</el-button>
 
 <el-dialog title="外層 Dialog" :visible.sync="outerVisible">
  <el-dialog
   width="30%"
   title="內(nèi)層 Dialog"
   :visible.sync="innerVisible"
   append-to-body>
  </el-dialog>
  <div slot="footer" class="dialog-footer">
   <el-button @click="outerVisible = false">取 消</el-button>
   <el-button type="primary" @click="innerVisible = true">打開內(nèi)層 Dialog</el-button>
  </div>
 </el-dialog>
</template>

<script>
 export default {
  data() {
   return {
    outerVisible: false,
    innerVisible: false
   };
  }
 }
</script>

Attributes


Slot

Events

Element 對話框簡單使用

官方文檔介紹的是頁內(nèi)對話框,但沒有基于組件的對話框,這里記錄一下,原理就是父子傳值是否顯示

父頁導(dǎo)入組件

<template>
  <div class="home">
    <el-button @click="btnAdd">添加用戶</el-button>
    <Dialog :visible.sync="visible" title="添加用戶"></Dialog>
  </div>
</template>

<script>
  import Dialog from "../components/dialog";

  export default {
    name: 'Home',
    components: {
      Dialog
    },
    data() {
      return {
        visible: false
      }
    },
    methods: {
      btnAdd() {
        this.visible = true
      }
    }
  }
</script>

對話框

<template>
  <div>
    <el-dialog
        v-bind="$attrs"
        v-on="$listeners"
        @open="onOpen"
        @close="onClose"
        :title="title"
        對話框打開后是否可以點擊后邊灰色區(qū)域關(guān)閉對話框
        :close-on-click-modal='false'>
      <el-row :gutter="15">
        <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="100px">
          <el-col :span="23">
            <el-form-item label="姓名" prop="userName">
              <el-input v-model="formData.userName" placeholder="請輸入姓名" :maxlength="50" clearable
                   prefix-icon='el-icon-user-solid' :style="{width: '100%'}"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="23">
            <el-form-item label="性別" prop="sex">
              <el-radio-group v-model="formData.sex" size="medium">
                <el-radio v-for="(item, index) in sexOptions" :key="index" :label="item.value"
                     :disabled="item.disabled">{{item.label}}
                </el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="23">
            <el-form-item label="生日" prop="birthday">
              <el-date-picker v-model="formData.birthday" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
                      :style="{width: '100%'}" placeholder="請選擇生日" clearable></el-date-picker>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <div slot="footer">
        <el-button @click="close">取消</el-button>
        <el-button type="primary" @click="handelConfirm">確定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
  export default {
    inheritAttrs: false,
    props: {
      title: String
    },
    data() {
      return {
        formData: {
          userName: undefined,
          sex: 3,
          birthday: null,
        },
        rules: {
          userName: [{
            required: true,
            message: '請輸入姓名',
            trigger: 'blur'
          }],
          sex: [{
            required: true,
            message: '性別不能為空',
            trigger: 'change'
          }],
          birthday: [{
            required: true,
            message: '請選擇生日',
            trigger: 'change'
          }],
        },
        sexOptions: [{
          "label": "男",
          "value": 1
        }, {
          "label": "女",
          "value": 2
        }, {
          "label": "保密",
          "value": 3
        }],
      }
    },
    methods: {
      onOpen() {
        //打開對話框執(zhí)行
      },
      onClose() {
        //關(guān)閉對話框執(zhí)行清除以上字段內(nèi)容
        this.$refs['elForm'].resetFields()
      },
      close() {
        //手工調(diào)用關(guān)閉,顯示狀態(tài)為隱藏
        this.$emit('update:visible', false)
      },
      handelConfirm() {
        this.$refs['elForm'].validate(valid => {
          if (valid) {
            //點擊確定后執(zhí)行驗證并執(zhí)行方法,執(zhí)行完畢后調(diào)用close()方法
            this.$message.success({
              message: "成功了"
            })
            this.close()
          }
        })
      }
    }
  }

</script>

執(zhí)行效果

到此這篇關(guān)于Element Dialog對話框的使用示例的文章就介紹到這了,更多相關(guān)Element Dialog對話框內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • vue.js 2.0實現(xiàn)簡單分頁效果

    vue.js 2.0實現(xiàn)簡單分頁效果

    這篇文章主要為大家詳細介紹了vue.js 2.0實現(xiàn)簡單分頁效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2019-07-07
  • 調(diào)用createApp?時Vue工作過程原理

    調(diào)用createApp?時Vue工作過程原理

    這篇文章主要為大家介紹了調(diào)用createApp?時Vue工作過程原理解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2023-01-01
  • Vue3全局配置Axios并解決跨域請求問題示例詳解

    Vue3全局配置Axios并解決跨域請求問題示例詳解

    axios 是一個基于promise的HTTP庫,支持promise所有的API,本文給大家介紹Vue3全局配置Axios并解決跨域請求問題,內(nèi)容從axios部署開始到解決跨域問題,感興趣的朋友一起看看吧
    2023-11-11
  • Vue中的table表單切換實現(xiàn)效果

    Vue中的table表單切換實現(xiàn)效果

    這篇文章主要介紹了Vue中的table表單切換實現(xiàn)效果,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-08-08
  • vue模態(tài)框?qū)崿F(xiàn)動態(tài)錨點

    vue模態(tài)框?qū)崿F(xiàn)動態(tài)錨點

    這篇文章主要為大家詳細介紹了vue模態(tài)框?qū)崿F(xiàn)動態(tài)錨點,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-07-07
  • Vue3使用dataV報錯問題的解決方法

    Vue3使用dataV報錯問題的解決方法

    這篇文章主要為大家詳細介紹了Vue3中使用dataV報錯問題的解決方法,文中的示例代碼講解詳細,具有一定的學(xué)習(xí)價值,感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下
    2023-11-11
  • Vue實現(xiàn)自定義組件改變組件背景色(示例代碼)

    Vue實現(xiàn)自定義組件改變組件背景色(示例代碼)

    要實現(xiàn) Vue 自定義組件改變組件背景色,你可以通過 props 將背景色作為組件的一個屬性傳遞給組件,在組件內(nèi)部監(jiān)聽這個屬性的變化,并將其應(yīng)用到組件的樣式中,下面通過示例代碼介紹Vue如何實現(xiàn)自定義組件改變組件背景色,感興趣的朋友一起看看吧
    2024-03-03
  • vue項目使用md5加密、crypto-js加密、國密sm3及國密sm4的方法

    vue項目使用md5加密、crypto-js加密、國密sm3及國密sm4的方法

    密碼或者其他比較重要東西假如使用明文傳輸中是很危險的,所以就需要前端一些加密協(xié)議,對密碼、手機號、身份證號等信息進行保護,下面這篇文章主要給大家介紹了關(guān)于vue項目中使用md5加密、crypto-js加密、國密sm3及國密sm4的相關(guān)資料,需要的朋友可以參考下
    2022-12-12
  • vue3簡單封裝input組件和統(tǒng)一表單數(shù)據(jù)詳解

    vue3簡單封裝input組件和統(tǒng)一表單數(shù)據(jù)詳解

    最近有一個需求是很多個表單添加,編輯等操作,會用到很多input輸入框,所以就想把input進行簡單封裝,這篇文章主要給大家介紹了關(guān)于vue3簡單封裝input組件和統(tǒng)一表單數(shù)據(jù)的相關(guān)資料,需要的朋友可以參考下
    2022-05-05
  • web面試vue自定義組件及調(diào)用方式

    web面試vue自定義組件及調(diào)用方式

    這篇文章主要介紹了web面試中常問到的關(guān)于vue自定義組件及調(diào)用方式,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步
    2021-09-09

最新評論

乌恰县| 蕉岭县| 昌黎县| 瓦房店市| 棋牌| 长沙县| 县级市| 大连市| 徐州市| 承德市| 宁波市| 扎赉特旗| 印江| 永顺县| 全南县| 通榆县| 武山县| 桦南县| 招远市| 讷河市| 南汇区| 衡南县| 常山县| 禹州市| 屯留县| 济南市| 吐鲁番市| 凤山县| 车致| 娱乐| 社旗县| 涡阳县| 绍兴县| 天长市| 徐州市| 达尔| 瓮安县| 若羌县| 二手房| 且末县| 阿鲁科尔沁旗|