3***@qq.com
3***@qq.com
  • 发布:2020-03-02 11:33
  • 更新:2021-06-09 11:04
  • 阅读:1623

app使用redirectTo方法切换页面闪屏

分类:uni-app

小米五手机荣耀v10手机都会出现这个问题

切换页面代码如下

<template>  
    <scroll-view scroll-y="true" show-scrollbar="false" :scroll-top="scrollTop"  @scroll="scroll">  
        <view v-for="(item,index) in dataList" :key="index" @tap="toPage(item)">  
            <text :class="{view1:true,green:item==pageIndex}">{{pageIndex==item}}</text>  
        </view>  
    </scroll-view>  
</template>  

<script>  
    import {  
        mapState,  
        mapMutations  
    } from 'vuex'  
    export default {  
        data() {  
            return {  
                dataList: [] ,  
                old: {  
                    scrollTop: 0  
                }  
            };  
        },  
        computed: mapState(['pageIndex','scrollTop']),  
        created() {  
            console.log("left created---",this.pageIndex)  
            for (let i = 1; i < 10; i++) {  
                this.dataList.push("page"+i)  
            }  
        },  
        methods:{  
            ...mapMutations(['setCurrentPage','setScrollTop']),  
            scroll(e) {  
                        this.old.scrollTop = e.detail.scrollTop  
                    },  
            toPage(item){  
                console.log(this.old.scrollTop+"--------"+this.scrollTop)  
                this.setScrollTop(this.old.scrollTop)  
                this.setCurrentPage(item)  
                uni.redirectTo({  
                    url: `../${item}/${item}`  
                })  
                // ({  
                //  url: `../${item}/${item}`  
                // })  
            }  
        }  
    }  
</script>  

<style>  
.view1{  
    background-color: red;  
    height: 200rpx;  
    text-align: center;   
    line-height: 200rpx;  
    border-bottom-width: 1rpx;  
}  
.green{  
    background-color: green;  
}  
</style>  
2020-03-02 11:33 负责人:无 分享
已邀请:
全栈工程师

全栈工程师 - 精通mui、uniapp,承接相关项目外包,解决各种疑难问题。有任何问题可以随时联系,QQ:419761282

楼主有解决这个问题吗

该问题目前已经被锁定, 无法添加新回复