当前位置:网站首页>小程序页面导航
小程序页面导航
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事件中直接获取到路由参数

边栏推荐
- When JS method passes long type ID value, precision loss will occur
- Scala basics [HelloWorld code parsing, variables and identifiers]
- [quick start to digital IC Verification] 8. Typical circuits in digital ICs and their corresponding Verilog description methods
- Jvmrandom cannot set seeds | problem tracing | source code tracing
- CTF reverse Foundation
- PyTorch 1.12发布,正式支持苹果M1芯片GPU加速,修复众多Bug
- 2020 CCPC 威海 - A. Golden Spirit(思维),D. ABC Conjecture(大数分解 / 思维)
- 处理文件和目录名
- 【数字IC验证快速入门】2、通过一个SoC项目实例,了解SoC的架构,初探数字系统设计流程
- [C language] merge sort
猜你喜欢

零道云新UI设计中

Leetcode brush question: binary tree 14 (sum of left leaves)

Leetcode skimming: binary tree 10 (number of nodes of a complete binary tree)

Guidelines for application of Shenzhen green and low carbon industry support plan in 2023

Leetcode: binary tree 15 (find the value in the lower left corner of the tree)

【愚公系列】2022年7月 Go教学课程 004-Go代码注释

JS implementation prohibits web page zooming (ctrl+ mouse, +, - zooming effective pro test)

【数字IC验证快速入门】9、Verilog RTL设计必会的有限状态机(FSM)

14. Users, groups, and permissions (14)

【数字IC验证快速入门】8、数字IC中的典型电路及其对应的Verilog描述方法
随机推荐
How to choose a good external disk platform, safe and formal?
B站UP搭建世界首个纯红石神经网络、基于深度学习动作识别的色情检测、陈天奇《机器学编译MLC》课程进展、AI前沿论文 | ShowMeAI资讯日报 #07.05
Ffplay document [easy to understand]
Some problems encountered in cocos2d-x project summary
Summer Challenge harmonyos - realize message notification function
Go language | 02 for loop and the use of common functions
mongodb/文档操作
Oracle-表空间管理
【数字IC验证快速入门】8、数字IC中的典型电路及其对应的Verilog描述方法
无卷积骨干网络:金字塔Transformer,提升目标检测/分割等任务精度(附源代码)...
Mongodb/ document operation
死信队列入门(两个消费者,一个生产者)
- Oui. Net Distributed Transaction and Landing Solution
实操演示:产研团队如何高效构建需求工作流?
Database logic processing function
Go language learning tutorial (XV)
强化学习-学习笔记4 | Actor-Critic
鸿蒙系统控制LED的实现方法之经典
Jvmrandom cannot set seeds | problem tracing | source code tracing
sort和投影