uni-app开发的iOS应用使用uni.navigateTo跳转四个页面后接着跳转第5个页面的时候就会卡死
uni-app开发的iOS应用使用uni.navigateTo跳转四个页面后接着跳转第5个页面的时候就会卡死
示例代码:
<template>
<view class="content">
<view class="content-box">
<view class="nav">
<view style=" width: 100%; color: #181818; font-size: 40rpx; text-align: center; margin-top: 112rpx; height: 40rpx; ">
开通数字证书
</view>
</view>
<view style="margin-top: 232rpx; text-align: center;" >
<image style="width: 320rpx; height: 320rpx;" src="../../../static/img/img_DC_open@3x.png" mode=""></image>
</view>
<view style="font-size: 36rpx;color: #333;text-align: center; margin-top: 32px; margin-bottom: 176rpx; ">
数字证书已开通
</view>
<button style="font-size: 36rpx;" @click="confirm" class="button-border-320">确定</button>
</view>
</view>
</template>
<script>
export default {
data() {
return {
againCert: ''
}
},
methods: {
confirm() {
let pages = getCurrentPages();
console.log("页面栈大小", pages.length)
pages.forEach(function(item, index){
let page = pages[index];
console.log("页面栈内容为:", index, page.route)
})
console.log("输出页面栈内容----结束")
uni.navigateTo({
url: "/pages/pay-account/cert/success-cert2",
fail: (error) => {
console.log("success-cert2跳转失败:", error)
}
})
}
}
}
</script>
<style lang="scss" scoped>
.content {
width: 100vw;
height: 100vh;
}
.content-box {
width: 100vw;
height: 100vh;
background: url('../../../static/img/log_bg.png') no-repeat;
background-size: 100% 50%;
}
.nav {
display: flex;
width: 100%;
height: 176rpx;
}
</style>
操作步骤:
使用uniapp开发的app应用,使用iOS离线打包基座打出的应用,在iphone12,15.6系统上,页面栈的深度达到4后,使用uni.navigateTo再跳转新的页面就会卡死。
预期结果:
页面栈的深度可以达到10,也就是说使用uni.navigateTo可以连续正常跳转10个页面。
实际结果:
使用uni.navigateTo,可以正常跳转4个页面。
bug描述:
使用uni.navigateTo跳转四个页面后,就会出现下面的报错信息,接着跳转第5个页面的时候就会卡死。
更多关于uni-app开发的iOS应用使用uni.navigateTo跳转四个页面后接着跳转第5个页面的时候就会卡死的实战教程也可以访问 https://www.itying.com/category-93-b0.html
你好,请问是有IOS企业证书吗?
更多关于uni-app开发的iOS应用使用uni.navigateTo跳转四个页面后接着跳转第5个页面的时候就会卡死的实战教程也可以访问 https://www.itying.com/category-93-b0.html
是的
老哥,方便qq或微信吗?
这是一个典型的iOS页面栈溢出问题。uni-app在iOS平台默认限制页面栈深度为5层(包括首页),超过这个限制会导致页面卡死或白屏。
从你的代码来看,当页面栈达到4层后继续使用uni.navigateTo就会触发这个问题。建议的解决方案:
- 检查页面跳转逻辑,避免过深的页面层级
- 对于不需要返回的页面使用uni.redirectTo替换uni.navigateTo
- 可以使用uni.reLaunch重置页面栈
- 在manifest.json中配置更大的页面栈限制(但可能影响性能):
"app-plus": {
"optimization": {
"subPackages": true
},
"launchwebview": {
"maximumPages": 10
}
}
另外,你可以在跳转前先检查当前页面栈深度:
let pages = getCurrentPages();
if(pages.length >= 5) {
uni.redirectTo({
url: "/pages/pay-account/cert/success-cert2"
});
} else {
uni.navigateTo({
url: "/pages/pay-account/cert/success-cert2"
});
}