?使用官方(Vant Weapp - 輕量、可靠的小程序 UI 組件庫)的before-close:?
wxml:?
<van-dialog use-slot title="名稱" show="{{ show }}" show-cancel-button bind:cancel="onClose" bind:confirm="getBackInfo" before-close="{{onBeforeClose}}">自定義內容
</van-dialog>
js:??
data: {show: false,onBeforeClose:''
},
getBackInfo() {if (this.data.XXX) {console.log('符合')} else {this.setData({show: true,onBeforeClose: (action) => { new Promise((resolve) => {if (action === 'confirm') { resolve(false)}})}}) console.log('不符合')}
},
onClose() {this.setData({show: false,});
},