UNPKG

wx-mini-weview

Version:

weixin UI

87 lines (77 loc) 1.52 kB
Component({ options: { styleIsolation: 'apply-shared', multipleSlots: true }, properties: { maskClosable: { type: Boolean, value: false }, confirmButtonText: { type: String, value: '确定' }, confirmButtonTheme: { type: String, value: 'wv-theme-light wv-content-dark' }, cancelButtonText: { type: String, value: '取消' }, cancelButtonTheme: { type: String, value: 'wv-theme-light wv-content-dark' }, showHeader: { type: Boolean, value: true }, showFooter: { type: Boolean, value: true } }, data: { content: '', header: '' }, lifetimes: { attached() { this.toast = this.selectComponent('#alert-toast'); } }, methods: { show(content, header = '', msgTheme = 'default') { if (this.toast) { this.setData({ content: content || '', header: header || '', msgTheme: msgTheme || 'default' }); this.toast.hide(); this.toast.showSlot(0); } }, hide() { if (this.toast) { this.toast.hideAll(); } }, onConfirmTap() { this.triggerEvent('confirm', { type: 'confirm', component: this }); this.hide(); }, onCancelTap() { this.triggerEvent('cancel', { type: 'cancel', component: this }); this.hide(); } } });