Skip to content

Commit

Permalink
perf(Tabs): avoid repeated initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan committed Nov 11, 2020
1 parent c941734 commit 599e817
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions src/tabs/index.js
@@ -1,12 +1,4 @@
import {
ref,
watch,
computed,
reactive,
nextTick,
onMounted,
onActivated,
} from 'vue';
import { ref, watch, computed, reactive, nextTick, onActivated } from 'vue';

// Utils
import {
Expand All @@ -30,6 +22,7 @@ import {
useWindowSize,
useScrollParent,
useEventListener,
onMountedOrActivated,
} from '@vant/use';
import { route } from '../composition/use-route';
import { useRefs } from '../composition/use-refs';
Expand Down Expand Up @@ -411,18 +404,13 @@ export default createComponent({
});
};

onMounted(init);

onActivated(() => {
init();
setLine();
});

useExpose({
resize: setLine,
scrollTo,
});

onActivated(setLine);
onMountedOrActivated(init);
useEventListener('scroll', onScroll, { target: scroller.value });

linkChildren({
Expand Down

0 comments on commit 599e817

Please sign in to comment.