使用Vant完成Dialog彈框案例
效果展示:
完整代碼:
<template> <!-- 完成Dialog 彈框 --> <div id="dialog"> <van-button class="btn" type="primary" @click="TipDialog">提示彈出框</van-button> <van-button class="btn" type="primary" @click="Dialog">(確認(rèn)、取消)的彈出框</van-button> </div> </template> <script> export default{ data(){ return{ msg:'' } }, methods:{ // 提示彈出框 TipDialog(){ this.$dialog.alert({ // title:'標(biāo)題呀', message:'彈框內(nèi)容' }).then(()=>{ console.log('點(diǎn)擊了確認(rèn)') }) }, //(確認(rèn)、取消)的彈出框 Dialog(){ this.$dialog.confirm({ title:'標(biāo)題奧', message:'哈哈哈哈,嗯嗯,Just do it', confirmButtonColor:'red' }).then(()=>{ console.log('點(diǎn)擊了確認(rèn)') }).catch(()=>{ console.log('點(diǎn)擊了取消') }) } }, mounted() { } } </script> <style> .btn{ margin:20px; } </style>
Dialog的相關(guān)API和Options參考:Dialog的相關(guān)API和Options詳見
補(bǔ)充知識(shí):van-dialog 彈出框之組件調(diào)用小結(jié) - Vue
van-dialog 彈出框之組件調(diào)用方法小結(jié),結(jié)合一些 api 中提供的屬性進(jìn)行組合搭配后的效果。
html
<button type="button" style="width: 100px; height: 30px;" @click="remarksPaperClick">備注</button> <van-dialog v-model="dialogShow" :show-cancel-button="true" :before-close="beforeClose"> <div style="width: 100%; height: 200px; display: flex; flex-direction: column; align-items: center;"> <span style="width: 100%; height: 30px; font-size: 20px; color: #ffffff; font-weight: bold; text-align: center; background-color: #37AAEA;">備注</span> <van-field v-model="remarkValue" placeholder="請(qǐng)輸入備注內(nèi)容" clearable autosize type="textarea" rows="1" maxlength="230" show-word-limit /> </div> </van-dialog>
js
remarksExamClick :function (item) { // 點(diǎn)擊事件 - 是否加載備注框組件 - 題目備注 console.log(item); }, beforeClose : function (action, done) { // 點(diǎn)擊事件 - 備注按鈕提示框 if (action === 'confirm') { // 確認(rèn) console.log('[點(diǎn)擊事件 - 備注] - 確認(rèn)'); done(); // 關(guān)閉提示框 } else if (action === 'cancel') { // 取消 console.log('[點(diǎn)擊事件 - 備注] - 取消'); done(); // 關(guān)閉提示框 } },
css 樣式根據(jù)實(shí)際業(yè)務(wù)場(chǎng)景需求自由配置即可。
以上這篇使用Vant完成Dialog彈框案例就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
基于Vue實(shí)現(xiàn)可選擇不連續(xù)的時(shí)間范圍的日期選擇器
這篇文章主要為大家詳細(xì)介紹了如何基于Vue.js實(shí)現(xiàn)一個(gè)可選擇不連續(xù)的時(shí)間范圍的日期選擇器,文中的示例代碼簡(jiǎn)潔易懂,需要的可以參考一下2023-06-06Antd表格滾動(dòng) 寬度自適應(yīng) 不換行的實(shí)例
這篇文章主要介紹了Antd表格滾動(dòng) 寬度自適應(yīng) 不換行的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2020-10-10vue 實(shí)現(xiàn)搜索的結(jié)果頁面支持全選與取消全選功能
這篇文章主要介紹了vue 實(shí)現(xiàn)搜索的結(jié)果頁面支持全選與取消全選功能,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-05-05Vue.js 中取得后臺(tái)原生HTML字符串 原樣顯示問題的解決方法
這篇文章主要介紹了VUE.js 中取得后臺(tái)原生HTML字符串 原樣顯示問題 ,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2018-06-06vue3使用element-plus搭建后臺(tái)管理系統(tǒng)之菜單管理功能
這篇文章主要介紹了vue3使用element-plus搭建后臺(tái)管理系統(tǒng)之菜單管理,使用element-plus el-tree組件快速開發(fā)樹形菜單結(jié)構(gòu),el-tree組件中filter-node-method事件便可以實(shí)現(xiàn)樹形菜單篩選過濾功能,需要的朋友可以參考下2022-04-04