Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ios长列表滚动位置无法缓存 #1

Open
zhanglong1009 opened this issue Dec 7, 2023 · 3 comments
Open

ios长列表滚动位置无法缓存 #1

zhanglong1009 opened this issue Dec 7, 2023 · 3 comments

Comments

@zhanglong1009
Copy link

<div class="keepA">
        <input type="text">
        <ul>
            <li class="li" @click="toNext(i)" v-for="i in 100">{{ i }}</li>
        </ul>
 </div>

ios真机调试时,长列表滚动后,没法缓存滚动的位置,会回到顶部。input的内容是正常缓存的。

@JoeshuTT
Copy link
Owner

JoeshuTT commented Dec 7, 2023

这个长列表的滚动容器样式css代码是怎么样的

@zhanglong1009
Copy link
Author

<template>
    <div class="keepA">
        <div>列表页面</div>
        <input type="text">
        <ul>
            <li class="li" @click="toNext(i)" :style="{background:`#${Math.floor(Math.random()*16777215).toString(16).padStart(6, '0')}`}" v-for="i in 100">{{ i }}</li>
        </ul>
    </div>
</template>

<script setup lang='ts'>
    import { useRouter } from 'vue-router';
    const router = useRouter()

    const toNext = (i: number) => {
        router.push({
            path: '/keepB',
            query: {
                no: i
            }
        })
    }
</script>

<style lang='scss' scoped>
    .li {
        height: 50px;
        text-align: center;
        line-height: 50px;
    }
</style>

这个是完整代码

@zhanglong1009
Copy link
Author

<template>
    <div class="keepA">
        <div>列表页面</div>
        <input type="text">
        <ul>
            <li class="li" @click="toNext(i)" :style="{background:`#${Math.floor(Math.random()*16777215).toString(16).padStart(6, '0')}`}" v-for="i in 100">{{ i }}</li>
        </ul>
    </div>
</template>

<script setup lang='ts'>
    import { useRouter } from 'vue-router';
    const router = useRouter()

    const toNext = (i: number) => {
        router.push({
            path: '/keepB',
            query: {
                no: i
            }
        })
    }
</script>

<style lang='scss' scoped>
    .li {
        height: 50px;
        text-align: center;
        line-height: 50px;
    }
</style>

这个是完整代码

QQ
这是效果图

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants