当前位置:网站首页>小程序页面导航
小程序页面导航
2022-07-05 20:19:00 【'wx】
1.什么是页面导航
页面导航指的是页面之间的相互跳转
2.小程序中实现页面导航的两种方式
(1).声明式导航
在页面上生明一个<navigator>导航组件
通过点击<navigator>组件实现页面跳转
(2)编程式导航
调用小程序的导航API,实现页面跳转
3.声明式导航
导航到tabBar页面
导航到非tabBar页面
<navigator url="/pages/info/info?name=xiaoming&age=20">
<button>传递参数</button>
</navigator>
注意:为了方便,在导航到非tabBar页面时,open-type属性可以省略
4.后退导航
注意,如果只后退到上衣页面,可以省略delta属性,其默认值就是1
5.编程式导航
调用wx.switchTab(Object object)方法,可以跳转到tabBar页面,其中Object参数对象的属性列表如下:
属性 | 类型 | 是否必选 | 说明 |
url | string | 是 | 需要跳转的 tabBar 页面的路径,路径后不能带参数 |
success | function | 否 | 接口调用成功的回调函数 |
fail | function | 否 | 接口调用失败的回调函数 |
complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
//页面结构
<view>编程式导航传参</view>
<button bindtap="goToInfo2">点击跳转到info</button>
//逻辑处理
goToInfo2(){
wx.navigateTo({
url: '/pages/info/info?name=lisi&age=20',
})
},
6.后退导航
调用wx.navigateBack(Object obkect)方法,可以返回上一页面或多级页面。
属性 | 类型 | 默认值 | 是否必选 | 说明 |
delta | number | 1 | 否 | 返回的页面数,如果 delta 大于现有 页面数,则返回到首页 |
success | function | 否 | 接口调用成功的回调函数 | |
fail | function | 否 | 接口调用失败的回调函数 | |
complete | function | 否 | 接口调用结束的回调函数( 调用成功、失败都会执行) |
7.导航传参
navigator组件的url属性用来指定将要跳转到的页面路径,路径后面可以携带参数
参数与路径间用?分割
参数键值对采用 = 方式
不同参数用&分割
可以在跳转路由的onLoad事件中直接获取到路由参数
边栏推荐
- 【c语言】快速排序的三种实现以及优化细节
- 信息学奥赛一本通 1338:【例3-3】医院设置 | 洛谷 P1364 医院设置
- Mysql频繁操作出现锁表问题
- [C language] merge sort
- Introduction to dead letter queue (two consumers, one producer)
- July 4, 2022 - July 10, 2022 (UE4 video tutorial MySQL)
- leetcode刷题:二叉树11(平衡二叉树)
- Is it safe for Galaxy Securities to open an account online?
- Jvmrandom cannot set seeds | problem tracing | source code tracing
- Flume series: interceptor filtering data
猜你喜欢
After 95, Alibaba P7 published the payroll: it's really fragrant to make up this
Oracle tablespace management
Go language | 01 wsl+vscode environment construction pit avoidance Guide
Leetcode brush question: binary tree 14 (sum of left leaves)
Parler de threadlocal insecurerandom
Guidelines for application of Shenzhen green and low carbon industry support plan in 2023
Leetcode brush questions: binary tree 11 (balanced binary tree)
死信队列入门(两个消费者,一个生产者)
.Net分布式事務及落地解决方案
Leetcode brush questions: binary tree 18 (largest binary tree)
随机推荐
About the priority of Bram IP reset
14. Users, groups, and permissions (14)
基础篇——配置文件解析
Mysql频繁操作出现锁表问题
DP:树DP
[quick start to digital IC Verification] 8. Typical circuits in digital ICs and their corresponding Verilog description methods
Leetcode(347)——前 K 个高频元素
【数字IC验证快速入门】7、验证岗位中必备的数字电路基础知识(含常见面试题)
Introduction to dead letter queue (two consumers, one producer)
解决Thinkphp框架应用目录下数据库配置信息修改后依然按默认方式连接
ICTCLAS用的字Lucene4.9捆绑
Leetcode: binary tree 15 (find the value in the lower left corner of the tree)
[quick start of Digital IC Verification] 7. Basic knowledge of digital circuits necessary for verification positions (including common interview questions)
Jvmrandom cannot set seeds | problem tracing | source code tracing
Debezium series: modify the source code to support UNIX_ timestamp() as DEFAULT value
Leetcode skimming: binary tree 16 (path sum)
怎么挑选好的外盘平台,安全正规的?
JS implementation prohibits web page zooming (ctrl+ mouse, +, - zooming effective pro test)
js方法传Long类型id值时会出现精确损失
Summer Challenge harmonyos - realize message notification function