编译后小程序里uni-app的uni.redirectTo不生效
编译后小程序里uni-app的uni.redirectTo不生效
示例代码:
<template>
<view class="content">
<image class="logo" src="/static/logo.png" />
<view class="text-area" @click="toPage">
<text class="title">{{ title }}</text>
</view>
</view>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const title = ref('Hello')
const toPage = () => {
uni.navigateTo({
url:"/pages/test/index",
})
}
</script>
操作步骤:
- https://gitee.com/dcloud/uni-preset-vue/tree/vite-ts 拉取代码后添加页面跳转方法,编译后在微信小程序打开
预期结果:
- 编译后小程序正常跳转页面
实际结果:
- 编译后小程序里页面不跳转
bug描述:
该框架编译后小程序里uni.redirectTo,uni.navigateTo都不生效,dev:h5正常跳转,pages.json里配了路径,不是跳转tabber页
附件
更多关于编译后小程序里uni-app的uni.redirectTo不生效的实战教程也可以访问 https://www.itying.com/category-93-b0.html
5 回复
Error: MiniProgramError {“errMsg”:“redirectTo:fail Error: INVALID_LOGIN,access_token expired [20250527 10:16:33][touristappid]”} 有一个,是不能用游客模式吗
回复 用户2823606: 你登录试试还有没有这个报错
回复 DCloud_UNI_JBB: 登录就可以了,感谢感谢
根据描述和截图分析,问题可能出在以下几个方面:
- 页面路径配置问题:
- 检查pages.json中是否正确定义了"/pages/test/index"页面路径
- 确保路径大小写一致,小程序平台对路径大小写敏感
- 编译配置问题:
- 检查manifest.json中微信小程序相关配置是否正确
- 确保编译时选择了正确的运行环境
- 代码写法问题:
- 建议使用完整路径写法:
/pages/test/index
(注意开头斜杠) - 可以尝试改用相对路径写法:
../test/index
- 微信小程序限制:
- 微信小程序对页面跳转有层级限制(最多10层)
- 检查是否已达到跳转层级上限
建议排查步骤:
- 先确认pages.json中是否包含以下配置:
"pages": [
...,
{
"path": "pages/test/index",
"style": {...}
}
]