jc_heisenberg
jc_heisenberg
  • 发布:2025-08-18 17:17
  • 更新:2025-08-18 17:17
  • 阅读:26

【报Bug】app.vue 到page.json第一个页面之间会有3-4秒的白屏延迟,并且page.json中也只配置了一个页面

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: win11专业版

HBuilderX类型: 正式

HBuilderX版本号: 4.75

手机系统: HarmonyOS NEXT

手机系统版本号: HarmonyOS 5.0.5

手机厂商: 华为

手机机型: nova 14

页面类型: vue

vue版本: vue3

打包方式: 离线

项目创建方式: HBuilderX

示例代码:

devEco studio 版本是 5.1.1 release

操作步骤:

多次测试出现一样的情况

预期结果:

1秒内延迟

实际结果:

多次测试还是有3-4秒白屏

bug描述:

App.vue代码:

export default {  

        onLaunch: function() {  
            uni.getSystemInfo({  
                success: function(res) {  
                    const screenWidth = res.screenWidth; // 屏幕宽度  
                    uni.setStorageSync('screenWidth', `?image_process=resize,w_${screenWidth}`);  
                },  
                fail: function(error) {  
                    console.log('获取系统信息失败', error);  
                }  
            });  
            // plus.navigator.closeSplashscreen();  
            // //应用初始化完成触发(只触发一次)  
            // const token = uni.getStorageSync('user_token'); //获取token  
            // if (token) {  
            //  //存在则关闭启动页进入首页  
            //  plus.navigator.closeSplashscreen();  
            // } else {  
            //  //不存在则跳转至登录页  
            //  uni.reLaunch({  
            //      url: "/pages/login_dl/login_dl",  
            //      success: () => {  
            //          plus.navigator.closeSplashscreen();  
            //      }  
            //  })  
            // }  

        },  
        onShow: function() {  
            console.log('App Show')  
        },  
        onHide: function() {  
            console.log('App Hide')  
        }  
    }  
</script>  

loading页面代码

<script>  
export default {  
    data() {  
        return {  
            seconds: 3,  
            img: '',  
            timer: null,  
            w: 0,  
            h: 0  
        }  
    },  
    onShow() {  
        if (this.seconds <= 0) {  
            this.Ontg()  
        }  
    },  
    onLoad() {  
        this.Onget()  
        var _this = this  
        // 监听是否有网络  
        var CALLBACK = function (res) {  
            if (res.networkType === "none") {  
                console.log("当前无网络");  
            } else {  
                console.log("当前网络正常");  
                clearInterval(this.timer)  
                //_this.Onget()  
            }  
        }  
        uni.offNetworkStatusChange(CALLBACK)  
        uni.onNetworkStatusChange(CALLBACK);  
    },  

    onUnload() {  
        clearInterval(this.timer)  
    },  
    methods: {  
        Onget() {  
            this.request({  
                url: '/souce/app_lodimg',  
                method: 'GET',  
            }).then(res => {  
                this.img = res.msg[0];  
                this.w = uni.getSystemInfoSync().screenWidth * 2;  
                this.h = uni.getSystemInfoSync().screenHeight * 2;  
                this.seconds = 3  
                this.timer = setInterval(() => {  
                    this.seconds--  
                    if (this.seconds <= 0) {  
                        clearInterval(this.timer)  
                        uni.switchTab({  
                            url: '/pages/index/index'  
                        })  
                        return  
                    }  
                }, 1000)  
            }, err => { })  
        },  
        Ontg() {  
            clearInterval(this.timer)  
            uni.reLaunch({  
                url: "/pages/index/index",  
                success: () => {  
                    plus.navigator.closeSplashscreen();  
                }  
            })  
        }  
    }  
}  
</script>  

page.json 代码:

{  
    "easycom": {  
        "autoscan": true,  
        // 注意一定要放在custom里,否则无效,https://ask.dcloud.net.cn/question/131175  
        "custom": {  
            "^u--(.*)": "@/uni_modules/uview-plus/components/u-$1/u-$1.vue",  
            "^up-(.*)": "@/uni_modules/uview-plus/components/u-$1/u-$1.vue",  
            "^u-([^-].*)": "@/uni_modules/uview-plus/components/u-$1/u-$1.vue"  
        }  
    },  
    "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages  
        {  
            "path": "pages/loading/loading",  
            "style": {  
                "navigationBarTitleText": "",  
                "navigationStyle": "custom" //默认显示原生导航栏  
            }  
        }  

    ],  

    "globalStyle": {  
        "navigationBarTextStyle": "black",  
        "navigationBarTitleText": "uni-app",  
        "navigationBarBackgroundColor": "#F8F8F8",  
        "backgroundColor": "#F8F8F8"  
    },  
    "tabBar": {  
        "color": "#7A7E83",  
        "selectedColor": "#3cc51f",  
        "borderStyle": "black",  
        "backgroundColor": "#ffffff",  
        "height": "50px",  
        "fontSize": "10px",  
        "list": [{  
            "pagePath": "pages/index/index",  
            "iconPath": "static/tabBar/icon_1.png",  
            "selectedIconPath": "static/tabBar/icon_1.png",  
            "text": "首页"  

        }, {  
            "pagePath": "pages/vehicle/vehicle",  
            "iconPath": "static/vehicle/gwc.png",  
            "selectedIconPath": "static/vehicle/gwc.png",  
            "text": "购物车"  
        }, {  
            "pagePath": "pages/my/my",  
            "iconPath": "static/tabBar/icon_2.png",  
            "selectedIconPath": "static/tabBar/icon_2.png",  
            "text": "我的"  
        }]  
    },  
    "uniIdRouter": {}  
}
2025-08-18 17:17 负责人:无 分享
已邀请:

要回复问题请先登录注册