当前位置:网站首页>[wechat applet development] page navigation and parameter transmission
[wechat applet development] page navigation and parameter transmission
2022-07-28 19:44:00 【Aricl.】
Catalog
2) Navigate to non tabBar page
2) Navigate to non tabBar page
1) Declarative navigation parameters
2) Programming navigation parameters
One 、 Page navigation
(1) summary
seeing the name of a thing one thinks of its function , Page navigation refers to the mutual jump between pages ,
And page parameter passing is to pass specific parameters to become parameters of the page when loading the page .
(2) classification
- Declarative navigation : Declare a... On the page <navigator> Navigation components , Click this component to realize page Jump
- Programming navigation : By calling the applet for special navigation API, Realize the jump between pages
(3) Declarative navigation
1) Navigate to tabBar page
tabBar The page refers to being configured as the bottom tabBar The page of , Click to switch quickly between pages
Configuration steps
- Statement <navigator> Components
- Appoint URL attribute , That is, the path of the page to jump to , Note that the path must be in / start
- Appoint open-type attribute , That is, the way to realize jump , Jump to tabBar The property of the page must be switchTab
Sample code
<navigator url="/pages/index/index" open-type="switchTab"> Navigate to home home page </navigator>
2) Navigate to non tabBar page
Not tabBar The page is not configured as the bottom tabBar The page of
Configuration steps
- Statement <navigator> Components
- Appoint URL attribute , That is, the path of the page to jump to , Note that the path must be in / start
- Appoint open-type attribute , That is, the way to realize jump , Jump to tabBar The property of the page must be navigator
- ( For development convenience , Official regulations at this time open-type Attributes can also be omitted without writing )
Sample code
<navigator url="/pages/info/info" open-type="navigate"> Navigate to info page </navigator>
3) Back navigation
Configuration steps
- Statement <navigator> Components
- Appoint open-type attribute , That is, the way to realize jump , Back jump this attribute must be navigateBack
- Appoint delta Value , Represents the number of layers to retreat , Must be Integers
Sample code
<navigator open-type="navigateBack" delta="1"> Back to previous page </navigator>
(4) Programming navigation
1) Navigate to tabBar page
Configuration steps
- Declare a button component
- Bind event functions for buttons
- Call in the time handler wx.switchTab(Object object) Method
- Specify url、success、fail Equal attribute
among object The attribute list of the parameter object is as follows :

( Be careful :url The attribute is mandatory , Others are optional )
Sample code :
.wxml
<button bindtap="gotoIndex" type="default"> Click to jump to home home page </button>
.js
// Click the event handler button , Jump to the home page
gotoIndex(){
wx.switchTab({
url: '/pages/index/index',
success:function(){
console.log(' Jump successful !')
},
fail:function(){
console.log(' Jump failure !')
},
complete:function(){
console.log(' Jump event has been triggered !')
}
})
}2) Navigate to non tabBar page
Configuration steps
- Declare a button component
- Bind event functions for buttons
- Call in the time handler wx.navigateTo(Object object) Method
- Specify url、success、fail Equal attribute
Sample code
The code is the same as the above , Just a calling applet API Different , You need to call wx.navigateTo(Object object) Method
3) Back navigation
Configuration steps
- Declare a button component
- Bind event functions for buttons
- Call in the time handler wx.navigateBack(Object object) Method
- Specify delta、success、fail Equal attribute
among object The attribute list of the parameter object is as follows :

Sample code
.wxml
<button bindtap="gotoBack" type="default"> Click to return to the previous page </button> .js
gotoBack(){
wx.navigateBack({
//delta The default value of the property is 1 , So the following sentence can be written or not
delta:1
})
}
(5) Navigation parameters
1) Declarative navigation parameters
navigator Component's url Property is used to specify the path of the page to jump to . meanwhile , Parameters can be carried behind the path :
- Use... Between parameters and paths ? Separate
- Between parameter key and parameter value = Connected to a
- Different parameters are used & Separate
Sample code
<navigator url="/pages/info/info?name=gy&number=1" open-type="navigate"> Navigate to info page </navigator>Result of parameter transmission

2) Programming navigation parameters
When calling wx.navigateTo(Object object) Method for page Jump , You can also carry parameters , It is the same as declarative navigation parameter passing , Write parameters into url in , The method is consistent
Sample code
gotoInfo(){
wx.navigateTo({
url: '/pages/info/info?name=gy&number=1',
success:function(){
console.log(' Jump successful !')
},
fail:function(){
console.log(' Jump failure !')
},
complete:function(){
console.log(' Jump event has been triggered !')
}
})
}边栏推荐
- 为什么在telnet登入界面下没有日志输出?
- 【微信小程序开发】页面导航与传参
- Report redirect after authorized login on wechat official account_ The problem of wrong URI parameters
- My second blog - C language
- Question bank and answers of the latest national fire-fighting facility operators (intermediate fire-fighting facility operators) in 2022
- 冲刺金九银十丨熬夜半个月汇集大厂Android岗1600道面试真题
- 可转债概念表 x Notion 给你方便快捷的体验!
- 11. Learn MySQL union operator
- NDK 系列(5):JNI 从入门到实践,爆肝万字详解!
- How to write the SQL statement of time to date?
猜你喜欢

CodeIgnier框架实现restful API接口编程

Cloud computing notes part.2 - Application Management

navicate修改数据库名的方式

Rust Getting Started Guide (modules and engineering structures)

架构基本概念和架构本质

Android section 13 03xutils detailed explanation of database framework (addition, deletion and modification)

When CNN meets transformer cmt:revolutionary neural networks meet vision transformers

基于MATLAB的函数拟合

Saltstack configuration management

App自动化测试是怎么实现H5测试的
随机推荐
英文翻译意大利语-批量英文翻译意大利语工具免费
Amazon launched Amazon one palm payment system, and the contactless palm vein recognition market is expected to explode
OpenOCD如何通过stlink直接下载程序到stm32板子(已解决)
idea properties文件显示\u不显示中文的解决
When CNN meets transformer cmt:revolutionary neural networks meet vision transformers
个人博克系统登录点击图形验证码的集成与实现
【笔记】《启示录》:产品经理的实践经验与反省清单
The United States will provide $25billion in subsidies to encourage chip manufacturers such as Intel to move back to production lines
使用SaltStack自动化部署Zabbix
MySQL8 Status Variables: Internal Temporary Tables and Files
Question bank and answers of the latest national fire-fighting facility operators (intermediate fire-fighting facility operators) in 2022
Saltstack system initialization
Huawei shares in Nanjing core vision, laying out the solid-state laser radar chip field
How does app automated testing achieve H5 testing
初步学习函数(第3篇博客)
NDK 系列(5):JNI 从入门到实践,爆肝万字详解!
Saltstack configuration management
App自动化测试是怎么实现H5测试的
Test Development Notes
MySQL8 基于clone创建主从复制