是否可以以编程方式清除和删除所有对话框和通知?

2020-10-15 17:02创建
共1个回答
EC
游客ecqXMk

可以使用shown 和destroyed事件来跟踪对话框。

    let _dialogs = []

    Vue.prototype.$dialog.on('shown', ({ dialog }) => _dialogs.push(dialog))

    Vue.prototype.$dialog.on(
      'destroyed',
      ({ dialog }) => (_dialogs = _dialogs.filter((_dialog) => _dialog.id !== dialog.id))
    )

    Vue.prototype.$dialog.clearDialogs = () => {
      _dialogs.forEach((_dialog) => _dialog.remove())
      _dialogs = []
    }