月牙哭
月牙哭
  • 发布:2022-09-21 16:15
  • 更新:2023-12-13 08:04
  • 阅读:293

横屏切换到竖屏后点返回上一页直接退出了app

分类:uni-app

问题描述 : 由竖屏切换至横屏, 再从横屏 ---> 竖屏, 点击竖屏顶部的返回首页时 直接退出app( IQOO手机正常,小米,华为出现直接退出app)

一.竖屏的返回代码

back() {  
    uni.navigateBack({  
        delta: 1  
    });

也尝试用过

uni.switchTab({  
    url: '/pages/index'  
});  也是直接退出了app  
}

二.竖屏到横屏的全过程

shu.vue ---> to.vue ---> heng.vue

三.横屏到竖屏的全过程
heng.vue ---> back.vue --->shu.vue

3.1 shu.vue ---> to.vue

uni.navigateTo({  
    url: '/pages/homeitem/to?pathpl='+'/pages/homeitem/LandingPoint'  
});

3.2to.vue 代码

onLoad(option) {  

        // #ifdef APP-PLUS  
        // 锁定横屏  
        plus.screen.lockOrientation("landscape-primary");  
            plus.navigator.setFullscreen(true) //隐藏状态栏  
        // #endif  
        // 待切换差不多时候重定向到 heng.vue 页面  
        // options.path 为 heng.vue 路由   
        this.time = setTimeout(function(){  
            console.log(option.pathpl,'路径')  
            uni.redirectTo({  
                url: option.pathpl  
            });  

        }, 2500)   
    },  
    beforeDestroy(){  
        clearTimeout(this.time)  
    },  
    onBackPress() {  
        // 防止用户在横竖屏切换过程中返回  
        return true  
    },

3.3 ---heng.vue 返回back.vue的代码

uni.redirectTo({
url: '/pages/homeitem/back'
})

3.4 ---back.vue 代码
data(){
return{
time:null,
}
},
onShow() {
// #ifdef APP-PLUS
plus.navigator.setFullscreen(false) //显示状态栏

         // #endif  
        // 进入此页面即刻退回上一页  
       uni.navigateBack({  
           delta: 1  
       });  

    },  
    onBackPress() {  
    // #ifdef APP-PLUS  
       // 锁定竖屏  
       plus.screen.lockOrientation("portrait-primary")  
     // #endif  
    },  
2022-09-21 16:15 负责人:无 分享
已邀请:
憨灬憨

憨灬憨

解决了吗?也碰到相同问题

拓荒

拓荒

请问解决了吗

要回复问题请先登录注册