fix(NoticeBar): failed to play when inside a re-opened popup (#8791)

This commit is contained in:
neverland 2021-06-01 10:21:32 +08:00 committed by GitHub
parent 38856e2e1c
commit c608f15f47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 0 deletions

View File

@ -58,9 +58,16 @@ export function PopupMixin(options = {}) {
}), }),
], ],
provide() {
return {
vanPopup: this,
};
},
props: popupMixinProps, props: popupMixinProps,
data() { data() {
this.onReopenCallback = [];
return { return {
inited: this.value, inited: this.value,
}; };
@ -135,6 +142,9 @@ export function PopupMixin(options = {}) {
this.opened = true; this.opened = true;
this.renderOverlay(); this.renderOverlay();
this.addLock(); this.addLock();
this.onReopenCallback.forEach((callback) => {
callback();
});
}, },
addLock() { addLock() {
@ -220,6 +230,10 @@ export function PopupMixin(options = {}) {
updateZIndex(value = 0) { updateZIndex(value = 0) {
this.$el.style.zIndex = ++context.zIndex + value; this.$el.style.zIndex = ++context.zIndex + value;
}, },
onReopen(callback) {
this.onReopenCallback.push(callback);
},
}, },
}; };
} }

View File

@ -14,6 +14,12 @@ export default createComponent({
}), }),
], ],
inject: {
vanPopup: {
default: null,
},
},
props: { props: {
text: String, text: String,
mode: String, mode: String,
@ -53,6 +59,14 @@ export default createComponent({
}, },
}, },
created() {
if (this.vanPopup) {
this.vanPopup.onReopen(() => {
this.start();
});
}
},
activated() { activated() {
this.start(); this.start();
}, },