组件调用,阻止点击确认按钮后关闭,resolve返回值搞不明白,反正就这么搞出来了,没有onLoad <!-- 拒绝弹窗 --> <van-dialog use-slot title="拒绝原因" show="{{ reject_model }}" show-cancel-button bind:confirm="submit_reject" bind:close="close_reject_model" bind:cancel="cancel_reject_model" before-close="{{beforeClose}}"> <van-field model:value="{{reject_reason}}" placeholder="请填写拒绝原因" type="textarea" required="{{false}}" autosize /> </van-dialog> /** * 点击拒绝 */ submit_reject() { let { detail, reject_reason } = this.data if (!reject_reason) { util.showToast('请填写拒绝原因') this.setData({ beforeClose: (action) => new Promise((resolve) => { if (action === 'confirm') { resolve(false) } else if (action === 'cancel') { resolve(false) } }), }) } else { this.setData({ beforeClose: (action) => new Promise((resolve) => { if (action === 'confirm') { resolve(true) } else if (action === 'cancel') { resolve(false) } }), }) const data = { examine: 3, reason: reject_reason, id: detail.id, } api .visitorAudit(data) .then(() => { util.showToast('已拒绝', 'success') setTimeout(() => { this.onShow() }, 500) }) .catch((err) => { return util.showToast(err.data.msg) }) } },
vant weapp Dialog中组件调用beforeClose这个是这么用的?[图片]这个正确的使用方式是什么。或者 有没有其他的方法可以让dialog关闭前校验
2022-12-27