Skip to content

Commit

Permalink
优化更新时机
Browse files Browse the repository at this point in the history
  • Loading branch information
xpyjs committed Jul 1, 2024
1 parent 2e5e7f5 commit d486aed
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/components/root/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ import Variables from '@/constants/vars';
import useExport from '@/composables/useExport';
import useElement from '@/composables/useElement';
import { setLocale } from '@/utils/date';
import useStore from '@/store';
const containerId = uuid(10);
const props = defineProps(rootProps);
Expand Down Expand Up @@ -133,6 +134,7 @@ onUpdated(getScrollGapSize);
// #region 得到组件高度,并保存
const { $param } = useParam();
const store = useStore();
const separateLineHeight = ref(0);
onMounted(() => {
const getHeight = () =>
Expand All @@ -147,11 +149,13 @@ onMounted(() => {
// 切换数据时,如果没有固定高度,那么整个高度应该随之变化。rootHeight 会决定渲染行数
watch(
() => props.data,
() => {
$param.rootHeight = getHeight();
nextTick(() => {
separateLineHeight.value = getHeight();
});
val => {
if (val.length !== store.$data.length) {
$param.rootHeight = getHeight();
nextTick(() => {
separateLineHeight.value = getHeight();
});
}
}
);
});
Expand Down

0 comments on commit d486aed

Please sign in to comment.