小程序开发报错:navigateTo:fail can not navigateTo a tabbar page
报错 not can 程序开发 Page fail tabBar
2023-09-27 14:22:11 时间
错误重现:
我新创建了一个小程序,项目暂时只有以下几个页面:
"pages": [
"pages/index/index",
"pages/logs/logs",
"pages/home/home"
],
同时,我在除了首页的其他页面添加了tabBar,
"tabBar": {
"list": [
{
"pagePath": "pages/home/home",
"text": "主页"
},
{
"pagePath": "pages/logs/logs",
"text": "日志"
}
]
},
此时,我想要在index页面中添加一个点击事件,事件响应后跳转home页面,我写了如下代码:
<button type="primary" bindtap="toHomePage">进入小程序</button>
toHomePage(){
wx.navigateTo({
url: '../home/home'
});
},
编译后点击button,出现了文章开头所示的报错。
错误分析:
经调查发现,wx.navigateTo
/wx.redirectTo
都不能跳转tarBar内的页面,所谓的tarBar页面,指的是app.json文件中的tarBar中注册的页面
解决报错:
解决这个报错有两种方法:
1、如果要跳转的页面确实需要在tabBar中注册,我们可以使用wx.switchTab
跳转tabBar页面
toHomePage(){
wx.switchTab({
url: '../home/home'
});
},
2、如果要跳转的页面不是必须在tabBar中注册,我们可以在tarBar项中删除目标页面对应的路径
相关文章
- 解决MySQL报错:1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'informat
- kubelet拉取pause镜像报错pull access denied for 172.20.59.190:81/kubernetes/pause-amd64, repository does not exist or may require 'docker login': denied
- 连接MySql报错Unknown system variable 'query_cache_size'
- 模型服务,GPU,CUDNN报错
- rocketmq-client-cpp 报错centos RPM should not be used directly install RPM packages, use Alien instead
- 报错:The specified datastore driver ("com.mysql.jdbc.Driver") was not found in the CLASSPATH. Please check your CLASSPATH specification, and the name of the driver.
- [转]html页面调用js文件里的函数报错onclick is not defined处理方法
- springboot启动feign项目报错:Service id not legal hostname
- 解决K8s报错:Error: error installing: the server could not find the requested resource
- 【informix】解决启动报错大全,以及解决办法
- springboot配置数据库密码特殊字符报错问题
- Hibernate分页查询报错
- yum报错https error 404 not found
- Maven-010-maven 编译报错:Failure to ... in ... was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced.
- linux tar解压到指定目录 报错Not found in archive
- Linux pip命令报错 -bash: pip: command not found
- 解决Vue用Nginx做web服务器报错favicon.ico 404 (Not Found)的问题
- Docker问题——Docker安装报错 Containers Windows Feature is not available
- Unity 之 切换语言导致报错:System.FormatException:String was not recognized as a valid DateTime.
- iOS开发- 支付宝2017.7.28为止最新SDK引入后直接报错和AL138173
- svn“Previous operation has not finished; run 'cleanup' if it was interrupted“报错的解决方法
- 小程序运行报错: navigateTo:fail page "pages/navigate/navigate" is not found?
- 解决控制台报错:Property or method “showInfo“ is not defined on the instance but referenced during render
- Exception from hresult 0x80041FE2,vs2015创建QT项目报错
- IDEA上Java项目启动全部报错