// arr1 is a long Array.
const arr1 = ref<any[]>([])
for (let i = 0; i < 100; i++) {
arr1.value.push({
name: i,
key: `key-${i}`,
})
}
const arr2 = computed(() => {
return arr1.value.slice(start.value, start.value + 10)
})
now, render arr2
by v-for
:
<view v-for="item in arr2" :key="item.key" class="item">
{{ item }}
</view>
Case 1 :
1、Scroll the list,and make arr2[0] partially hidden
:
2、Click the test button
Android device :
arr2[1]
is now at top of the page.
IOS devicce :
arr2[1]
scrolled to arr2[0]
.
Case 2:
1、Scroll the list, and make a lot of items hidden:
2、Click the test button
Android device :
The page has no change:
IOS devicce :
Question:
What went wrong? And how to make their behavior consistent?
Here is the test project:
scroll-vue.zip