当前位置:网站首页>[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 !')
}
})
}边栏推荐
- adb remount of the / superblock failed: Permission denied
- 亚马逊推出Amazon One手掌支付系统,非接触式掌静脉识别市场有望爆发
- Report redirect after authorized login on wechat official account_ The problem of wrong URI parameters
- 远光软件获得阿里云产品生态集成认证,携手阿里云共建新合作
- String中常用的API
- This customized keyboard turns me on~
- 11. Learn MySQL union operator
- OpenOCD如何通过stlink直接下载程序到stm32板子(已解决)
- 博途1200/1500PLC上升沿下降沿指令编程应用技巧(bool数组)
- STC12C5A60S2 function description (STC12C5A60S2 is triggered by default)
猜你喜欢

How does app automated testing achieve H5 testing

Cell review: single cell methods in human microbiome research

Oracle insert数据时字符串中有‘单引号问题

Servlet learning notes

Android-第十三节03xUtils-数据库框架(增删改查)详解

云计算笔记part.2——应用管理

Integration and implementation of login click graphic verification code in personal blog system

How does app automated testing achieve H5 testing

基于C语言的信息管理系统和小游戏

idea properties文件显示\u不显示中文的解决
随机推荐
业务可视化-让你的流程图“Run“起来(4.实际业务场景测试)
Force buckle 1331. Array serial number conversion
Report redirect after authorized login on wechat official account_ The problem of wrong URI parameters
My second blog - C language
R language and data analysis practice 11 - data deletion
Failed to install app-debug.apk: Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI]
Taking the opportunity of digital transformation, how can 3C enterprises achieve efficient collaboration through SRM supplier cloud collaboration platform?
leetcode day5 删除重复的电子邮箱
华为入股南京芯视界,布局固态激光雷达芯片领域
First blog
Huawei shares in Nanjing core vision, laying out the solid-state laser radar chip field
shared_ptr 和 make_shared 的使用
亚马逊推出Amazon One手掌支付系统,非接触式掌静脉识别市场有望爆发
NetCoreAPI操作Excel表格
OpenOCD如何通过stlink直接下载程序到stm32板子(已解决)
初步学习函数(第3篇博客)
The United States will provide $25billion in subsidies to encourage chip manufacturers such as Intel to move back to production lines
When CNN meets transformer cmt:revolutionary neural networks meet vision transformers
MySQL8 基于clone创建主从复制
Android section 13 03xutils detailed explanation of database framework (addition, deletion and modification)