組件之間數據通信
調用組件wxml
bind+組件內的方法名
<dialog bindclose="handleClose" bindopen="handleOpen" bindconfirm="handleConfirm"> </dialog>
調用組件js
// 打開 handleOpen: function() { wx.showToast({ title: 'open dialog', icon: 'none' }) }, // 確認 handleConfirm: function() { wx.showToast({ title: 'confirm', icon: 'none' }) }, // 取消 handleClose: function() { wx.showToast({ title: 'close dialog', icon: 'none' }) }
組件內的js
methods: { close() { this.closedialog(); this.triggerEvent('close'); }, confirm() { this.closedialog(); this.triggerEvent('confirm'); } }
傳遞參數呢?
<dialog data-model="dialogConfig.dialogvisible" data-ok="okok"> </dialog>
詳情參考知乎VUE文檔:https://www.jianshu.com/p/8b1c8609bbab