fix(NoticeBar): fix cache issues with forwards and back history in safari (#7167)

This commit is contained in:
neverland 2020-09-12 08:28:47 +08:00 committed by GitHub
parent 61106313dc
commit 60ce34d4a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,10 +1,19 @@
import { createNamespace, isDef } from '../utils';
import { doubleRaf } from '../utils/dom/raf';
import { BindEventMixin } from '../mixins/bind-event';
import Icon from '../icon';
const [createComponent, bem] = createNamespace('notice-bar');
export default createComponent({
mixins: [
BindEventMixin(function (bind) {
// fix cache issues with forwards and back history in safari
// see: https://guwii.com/cache-issues-with-forwards-and-back-history-in-safari/
bind(window, 'pageshow', this.start);
}),
],
props: {
text: String,
mode: String,
@ -83,7 +92,8 @@ export default createComponent({
this.reset();
setTimeout(() => {
clearTimeout(this.startTimer);
this.startTimer = setTimeout(() => {
const { wrap, content } = this.$refs;
if (!wrap || !content || this.scrollable === false) {
return;