1.注意beforeClose是data中的变量
2.onConfirm确定事件就可以阻断关闭弹框了,手动关闭可以调用this.onClose()

<van-dialog
	title="安全校验"
	show="{{isShow}}"
	use-slot
	show-cancel-button
	bind:confirm="onConfirm"
	bind:close="onClose"
	beforeClose="{{beforeClose}}"
>
	<view>xxx</view>
</van-dialog>
data: {
	isShow: false,
	beforeClose(action) {
		return new Promise(resolve => {
			if (action === 'confirm') {
				resolve(false);
			} else {
				resolve(true);
			}
		});
	}
},
// 确定事件
onConfirm() {
	this.onClose(); // 手动关闭
},
// 关闭弹框
onClose() {
	this.setData({
		isShow: false
	});
},
GitHub 加速计划 / va / vant-weapp
17.63 K
3.47 K
下载
轻量、可靠的小程序 UI 组件库
最近提交(Master分支:2 个月前 )
d25ded55 Bumps [ws](https://github.com/websockets/ws) from 7.5.6 to 7.5.10. - [Release notes](https://github.com/websockets/ws/releases) - [Commits](https://github.com/websockets/ws/compare/7.5.6...7.5.10) --- updated-dependencies: - dependency-name: ws dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> 4 个月前
f6cb13ba 4 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐