使用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">(確認、取消)的彈出框</van-button>
</div>
</template>
<script>
export default{
data(){
return{
msg:''
}
},
methods:{
// 提示彈出框
TipDialog(){
this.$dialog.alert({
// title:'標(biāo)題呀',
message:'彈框內(nèi)容'
}).then(()=>{
console.log('點擊了確認')
})
},
//(確認、取消)的彈出框
Dialog(){
this.$dialog.confirm({
title:'標(biāo)題奧',
message:'哈哈哈哈,嗯嗯,Just do it',
confirmButtonColor:'red'
}).then(()=>{
console.log('點擊了確認')
}).catch(()=>{
console.log('點擊了取消')
})
}
},
mounted() {
}
}
</script>
<style>
.btn{
margin:20px;
}
</style>
Dialog的相關(guān)API和Options參考:Dialog的相關(guān)API和Options詳見
補充知識:van-dialog 彈出框之組件調(diào)用小結(jié) - Vue
van-dialog 彈出框之組件調(diào)用方法小結(jié),結(jié)合一些 api 中提供的屬性進行組合搭配后的效果。

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="請輸入備注內(nèi)容"
clearable
autosize
type="textarea"
rows="1"
maxlength="230"
show-word-limit
/>
</div>
</van-dialog>
js
remarksExamClick :function (item) { // 點擊事件 - 是否加載備注框組件 - 題目備注
console.log(item);
},
beforeClose : function (action, done) { // 點擊事件 - 備注按鈕提示框
if (action === 'confirm') { // 確認
console.log('[點擊事件 - 備注] - 確認');
done(); // 關(guān)閉提示框
} else if (action === 'cancel') { // 取消
console.log('[點擊事件 - 備注] - 取消');
done(); // 關(guān)閉提示框
}
},
css 樣式根據(jù)實際業(yè)務(wù)場景需求自由配置即可。
以上這篇使用Vant完成Dialog彈框案例就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
vscode 使用Prettier插件格式化配置使用代碼詳解
這篇文章主要介紹了vscode 使用Prettier插件格式化配置使用,本文給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-08-08
vuecli項目構(gòu)建SSR服務(wù)端渲染的實現(xiàn)
這篇文章主要介紹了vuecli項目構(gòu)建SSR服務(wù)端渲染的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-10-10
詳解Vue的watch中的immediate與watch是什么意思
這篇文章主要介紹了詳解Vue的watch中的immediate與watch是什么意思,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-12-12
vue3如何使用watch監(jiān)聽props中的數(shù)據(jù)
在vue項目中,父子組件數(shù)據(jù)傳遞是最常見的場景,但是今天在開發(fā)過程中父級數(shù)據(jù)傳遞到子組件,控制子組件的顯隱,下面這篇文章主要給大家介紹了關(guān)于vue3如何使用watch監(jiān)聽props中數(shù)據(jù)的相關(guān)資料,需要的朋友可以參考下2022-10-10
使用vue-resource進行數(shù)據(jù)交互的實例
下面小編就為大家?guī)硪黄褂胿ue-resource進行數(shù)據(jù)交互的實例。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-09-09

