使用Vant完成Dialog弹框案例
编程学习 2021-07-04 14:07www.dzhlxh.cn编程入门
这篇文章主要介绍了使用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:'标题呀',
message:'弹框内容'
}).then(()=>{
console.log('点击了确认')
})
},
//(确认、取消)的弹出框
Dialog(){
this.$dialog.confirm({
title:'标题奥',
message:'哈哈哈哈,嗯嗯,Just do it',
confirmButtonColor:'red'
}).then(()=>{
console.log('点击了确认')
}).catch(()=>{
console.log('点击了取消')
})
}
},
mounted() {
}
}
</script>
<style>
.btn{
margin:20px;
}
</style>
Dialog的相关API和Options参考:
补充知识:van-dialog 弹出框之组件调用小结 - Vue
van-dialog 弹出框之组件调用方法小结,结合一些 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="请输入备注内容"
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(); // 关闭提示框
} else if (action === 'cancel') { // 取消
console.log('[点击事件 - 备注] - 取消');
done(); // 关闭提示框
}
},
css 样式根据实际业务场景需求自由配置即可。
以上这篇使用Vant完成Dialog弹框案例就是长沙网络推广分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持狼蚁SEO。
编程语言
- ThinkPad 笔记本如何调节LCD屏幕亮度
- Dreamweaver制作网页打开特效教程
- Win10 Mobile 10586升级后无限重启怎么办 硬重启帮您
- Win8系统提示音频设备有问题有一个或多个音频服
- Xbox One版Win10首个预览版9月份发布
- 如何在textarea文本输入区内实现换行
- Win10 Build 9901系统更新 预览版新版本下载
- McAfee Framework存在远程格式串处理漏洞
- Win10家庭版今日(7月30)正式在中国官方商城开卖
- Win10 Mobile预览版更新完10536.1000后才收到10536.100
- Win10 RS2更新了什么-Win10 RS2最终版本号1704首曝
- Windows7如何查看回收站对应的文件夹有哪些方法
- Win10让Charms栏回归桌面的方法教程
- 取消Windows XP系统开机启动画面的小技巧
- win8系统怎么下载安装USB百兆网卡?
- XP系统下磁盘空间变少了怎么办?XP系统磁盘空间