diff --git a/src/packages/__VUE/list/index.taro.vue b/src/packages/__VUE/list/index.taro.vue index de6528a4ab..374917e660 100644 --- a/src/packages/__VUE/list/index.taro.vue +++ b/src/packages/__VUE/list/index.taro.vue @@ -39,7 +39,6 @@ import NutScrollView from '../scroll-view/index.taro.vue'; import { useTaroRect } from '@/packages/utils/useTaroRect'; import { CachedPosition, CompareResult, binarySearch } from './type'; const { create } = createComponent('list'); -const clientHeight = Taro.getSystemInfoSync().windowHeight || 667; export default create({ components: { @@ -61,8 +60,7 @@ export default create({ default: 5 }, containerHeight: { - type: [Number], - default: clientHeight + type: Number }, estimateRowHeight: { type: Number, @@ -76,6 +74,7 @@ export default create({ emits: ['scrollUp', 'scrollDown', 'scrollBottom'], setup(props, { emit }) { + const clientHeight = Taro.getSystemInfoSync?.()?.windowHeight || 667; const list = ref(null) as Ref; const phantom = ref(null) as Ref; const actualContent = ref(null) as Ref; @@ -90,7 +89,10 @@ export default create({ }); const getContainerHeight = computed(() => { - return Math.min(props.containerHeight, clientHeight); + if (props.containerHeight) { + return Math.min(props.containerHeight, clientHeight); + } + return clientHeight; }); const visibleCount = computed(() => { diff --git a/src/packages/__VUE/list/index.vue b/src/packages/__VUE/list/index.vue index d8ef066960..0c147613a7 100644 --- a/src/packages/__VUE/list/index.vue +++ b/src/packages/__VUE/list/index.vue @@ -14,7 +14,6 @@ import { createComponent } from '@/packages/utils/create'; import { CachedPosition, CompareResult, binarySearch } from './type'; import { useRect } from '@/packages/utils/useRect'; const { create } = createComponent('list'); -const clientHeight = document.documentElement.clientHeight || document.body.clientHeight || 667; export default create({ props: { @@ -29,8 +28,7 @@ export default create({ default: 5 }, containerHeight: { - type: [Number], - default: clientHeight + type: Number }, height: { type: Number, @@ -44,6 +42,7 @@ export default create({ emits: ['scrollUp', 'scrollDown', 'scrollBottom'], setup(props, { emit }) { + const clientHeight = document.documentElement.clientHeight || document.body.clientHeight || 667; const list = ref(null) as Ref; const phantom = ref(null) as Ref; const actualContent = ref(null) as Ref; @@ -57,7 +56,10 @@ export default create({ }); const getContainerHeight = computed(() => { - return Math.min(props.containerHeight, clientHeight); + if (props.containerHeight) { + return Math.min(props.containerHeight, clientHeight); + } + return clientHeight; }); const visibleCount = computed(() => {