fix(IndexBar): failed to render active anchor when inited (#8164)

This commit is contained in:
neverland
2021-02-16 10:57:19 +08:00
committed by GitHub
parent 57a36967c5
commit 9e05d21445
2 changed files with 21 additions and 10 deletions
+16 -7
View File
@@ -1,4 +1,12 @@
import { ref, watch, computed, nextTick, PropType, CSSProperties } from 'vue';
import {
ref,
watch,
computed,
nextTick,
PropType,
onMounted,
CSSProperties,
} from 'vue';
// Utils
import {
@@ -165,14 +173,15 @@ export default createComponent({
}
};
const init = () => {
nextTick(onScroll);
};
useEventListener('scroll', onScroll, { target: scrollParent });
watch(
() => props.indexList,
() => {
nextTick(onScroll);
}
);
onMounted(init);
watch(() => props.indexList, init);
watch(activeAnchor, (value) => {
if (value) {