当前位置:网站首页>小程序页面导航
小程序页面导航
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事件中直接获取到路由参数
边栏推荐
- 本季度干货导航 | 2022年Q2
- 【数字IC验证快速入门】7、验证岗位中必备的数字电路基础知识(含常见面试题)
- ByteDance dev better technology salon was successfully held, and we joined hands with Huatai to share our experience in improving the efficiency of web research and development
- .Net分布式事務及落地解决方案
- Go language | 02 for loop and the use of common functions
- PyTorch 1.12发布,正式支持苹果M1芯片GPU加速,修复众多Bug
- Leetcode brush question: binary tree 14 (sum of left leaves)
- Let's talk about threadlocalinsecurerandom
- 【数字IC验证快速入门】9、Verilog RTL设计必会的有限状态机(FSM)
- 19 Mongoose模块化
猜你喜欢
【数字IC验证快速入门】9、Verilog RTL设计必会的有限状态机(FSM)
Leetcode: binary tree 15 (find the value in the lower left corner of the tree)
.Net分布式事務及落地解决方案
零道云新UI设计中
[Yugong series] go teaching course in July 2022 004 go code Notes
leetcode刷题:二叉树16(路径总和)
Practical demonstration: how can the production research team efficiently build the requirements workflow?
淺淺的談一下ThreadLocalInsecureRandom
B站UP搭建世界首个纯红石神经网络、基于深度学习动作识别的色情检测、陈天奇《机器学编译MLC》课程进展、AI前沿论文 | ShowMeAI资讯日报 #07.05
kubernetes资源对象介绍及常用命令(五)-(ConfigMap&Secret)
随机推荐
CTF逆向基础
JS implementation prohibits web page zooming (ctrl+ mouse, +, - zooming effective pro test)
Introduction to dead letter queue (two consumers, one producer)
Autumn byte interviewer asked you any questions? In fact, you have stepped on thunder
【数字IC验证快速入门】1、浅谈数字IC验证,了解专栏内容,明确学习目标
Leetcode skimming: binary tree 10 (number of nodes of a complete binary tree)
Mysql频繁操作出现锁表问题
About the priority of Bram IP reset
计算lnx的一种方式
Go language | 02 for loop and the use of common functions
《乔布斯传》英文原著重点词汇笔记(十二)【 chapter ten & eleven】
Is it safe for Galaxy Securities to open an account online?
Bzoj 3747 poi2015 kinoman segment tree
2020 CCPC 威海 - A. Golden Spirit(思维),D. ABC Conjecture(大数分解 / 思维)
Notes on key vocabulary in the English original of the biography of jobs (12) [chapter ten & eleven]
中金财富在网上开户安全吗?
零道云新UI设计中
本季度干货导航 | 2022年Q2
Leetcode brush questions: binary tree 11 (balanced binary tree)
DP:树DP