diff --git a/src/mixins/popup/index.js b/src/mixins/popup/index.js index 6c458cf82..4d6ef394c 100644 --- a/src/mixins/popup/index.js +++ b/src/mixins/popup/index.js @@ -58,9 +58,16 @@ export function PopupMixin(options = {}) { }), ], + provide() { + return { + vanPopup: this, + }; + }, + props: popupMixinProps, data() { + this.onReopenCallback = []; return { inited: this.value, }; @@ -135,6 +142,9 @@ export function PopupMixin(options = {}) { this.opened = true; this.renderOverlay(); this.addLock(); + this.onReopenCallback.forEach((callback) => { + callback(); + }); }, addLock() { @@ -220,6 +230,10 @@ export function PopupMixin(options = {}) { updateZIndex(value = 0) { this.$el.style.zIndex = ++context.zIndex + value; }, + + onReopen(callback) { + this.onReopenCallback.push(callback); + }, }, }; } diff --git a/src/notice-bar/index.js b/src/notice-bar/index.js index 43454c9c9..a1519ce63 100644 --- a/src/notice-bar/index.js +++ b/src/notice-bar/index.js @@ -14,6 +14,12 @@ export default createComponent({ }), ], + inject: { + vanPopup: { + default: null, + }, + }, + props: { text: String, mode: String, @@ -53,6 +59,14 @@ export default createComponent({ }, }, + created() { + if (this.vanPopup) { + this.vanPopup.onReopen(() => { + this.start(); + }); + } + }, + activated() { this.start(); },