mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-22 22:49:15 +08:00
perf(NoticeBar): avoid repeated start
This commit is contained in:
parent
599e817cd4
commit
0712d92063
@ -1,8 +1,14 @@
|
|||||||
import { ref, watch, reactive, onActivated } from 'vue';
|
import { ref, watch, reactive } from 'vue';
|
||||||
import { isDef, createNamespace } from '../utils';
|
import { isDef, createNamespace } from '../utils';
|
||||||
|
|
||||||
// Composition
|
// Composition
|
||||||
import { raf, useRect, doubleRaf, useEventListener } from '@vant/use';
|
import {
|
||||||
|
raf,
|
||||||
|
useRect,
|
||||||
|
doubleRaf,
|
||||||
|
useEventListener,
|
||||||
|
onMountedOrActivated,
|
||||||
|
} from '@vant/use';
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
import Icon from '../icon';
|
import Icon from '../icon';
|
||||||
@ -159,15 +165,13 @@ export default createComponent({
|
|||||||
}, ms);
|
}, ms);
|
||||||
};
|
};
|
||||||
|
|
||||||
onActivated(start);
|
onMountedOrActivated(start);
|
||||||
|
|
||||||
// fix cache issues with forwards and back history in safari
|
// fix cache issues with forwards and back history in safari
|
||||||
// see: https://guwii.com/cache-issues-with-forwards-and-back-history-in-safari/
|
// see: https://guwii.com/cache-issues-with-forwards-and-back-history-in-safari/
|
||||||
useEventListener('pageshow', start);
|
useEventListener('pageshow', start);
|
||||||
|
|
||||||
watch([() => props.text, () => props.scrollable], start, {
|
watch([() => props.text, () => props.scrollable], start);
|
||||||
immediate: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
const { color, wrapable, background } = props;
|
const { color, wrapable, background } = props;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user