当前位置:网站首页>【 WeChat applet 】 read page navigation
【 WeChat applet 】 read page navigation
2022-08-10 08:29:00 【The front-end Xiao Liu is not afraid of Niu Niu】
写在前面:
观众老爷们好呀,这里是前端小刘不怕牛牛频道,The applet series has been updated again,Today's content is the page navigation of the WeChat applet,非常重要,Quickly pick up the notebook and remember it!

文章目录
一,页面导航
首先,Let's first understand what page navigation is,In fact, it is to jump to the page by identifying the user's click.
这一点有点类似于vue
中的vue-router
路由,我们可以通过<router-link>
The tag implements the rendering of divided pages within a single page,It's just that the page navigation of the applet is relatively speaking,比较简单.
There are two types of page navigation in the applet,声明式导航和编程式导航,话不多说,我们现在正式开始.
1.1 声明式导航
Declarative navigation is the use of applet<navigator>
实现的,其中有url
属性,It's like a browser in effecta
超链接标签.
1.1.1 导航到tarBar页面
Remember what we learned earliertarBar
是啥不,底部的导航栏,Click to jump to the corresponding page,而用<navigator>
也可以实现.
We need to set two properties in navigator
组件中,url
和open-type
.
url
:Set the location of the page that needs to be jumped(页面地址),And it must be preceded by/
开头,比如——url = '/pages/content/conten'
最后一个contentNo need to add file suffix.open-type
:设置navigator
的跳转方式,Here the selection value isswitchTab
,Indicates that the jumping page is configured totarBar
中的.tarBar
页面配置:
在app.json
文件中
In this way, we realize the click to jump totarBar
in the settings page.
<navigator url="/pages/list/list">点击跳转</navigator>
You can also nest other components inside,Such as nesting onebutton
.
1.1.2 导航到非tarBar页面
非tarBar
The page is where you arepage
Folder already defined pages,但是没有在app.json
中的tarBar
配置.
在实际开发中,This kind of scene is very common,A more complex applet will have more pages,And so many pages will not be theretarBar
中配置,All such page jumps have to rely on this method to achieve it.
与上文一样,也是需要url
和open-type
两个属性,url
的写法不变,有变化的是open-type
The value of needs to benavigate
.
<navigator url="/pages/list/list" open-type='navigate'>
</navigator>
1.1.3 后退导航
<navigator>
You can also implement the page back function.
At this time we don't need to set iturl
属性了,需要更改的是,设置open-type
的值为navigateBack
.
我们可以通过设置delta
Set the level of fallback,如果不设置,Then the default value will be 1.
<navigator open-type="navigateBack" delta='1'></navigator>
1.2 编程式导航
Programmatic navigation is the use of WeChat Mini Program top-level objectswx
The following methods can be implemented,Next we will explain them one by one.
1.2.1 导航到tarBar页面
我们将使用wx
下的switchTab(obj)
方法,其中obj
为对象.
There are four properties in an object,url
、success
、fail
、complete
.
其中`
url
is the address of the page to jump tosuccess
It is the callback function for the successful execution of the interface callfail
It is the callback function that is executed when the interface call failscomplete
Is the callback function that completes the call execution,无论成功与否,都会执行.
wx.swithTab({
url : '/pages/list/list',
...
)}
1.2.2 导航到非tarBar页面
To achieve this function we need to callwx
下的navigateTo(obj)
方法.
The parameter types in the object and 1.2.1一致.
wx.navigateTo({
url : '/page/list/list',
success : function(){
console.log('success');}
})
1.2.3 后退导航
Here's the back navigation feature,We need to use the samewx
under the top-level objectnavigateBack(obj)
方法.
不过不同的是,obj
对象中的参数,url
改为delta
,said to be back 层级,默认值为1,That is, go back one page.
1.3 导航传参
If we implement page jump after,When the next page wants to call the parameters of the previous page,我们该怎么办?
At this time, you can use the navigation parameters,Navigation parameters are actually and used in the browserGET请求很像,Parameters can be set in url
中,Pass to the next page.
The format is also through the method of key-value pairs,Used between paths and parameters?
隔开,键与值之间用=
隔开,used between each parameter&
隔开.
如下所示:
url= "/pages/list/list?name=myname&pass=yes"
今天的小程序文章到这里就结束啦,如果觉得对您有帮助的话,可以关注牛牛接下来的文章,感谢您对支持,您的支持是我创作的最大动力!!!
债见~~
边栏推荐
- DAY25:逻辑漏洞复现
- js函数聚合的三种实现方式
- 本地生活商家如何通过短视频赛道,提升销量曝光量?
- A File Online Query Display and Download Function Realized by Delphi
- DGIOT supports industrial equipment rental and remote control
- phpstudy starts automatically
- 基于sklearn的决策树应用实战
- JS reduce
- The implementation of the seemingly useless component (text gradient) in NaiveUI is so simple
- 机器人控制器编程实践指导书旧版-实践二 传感器(模拟量)
猜你喜欢
DAY26:GetShell专题
【搜索引擎】Solr:提高批量索引的性能
【Unity入门计划】制作RubyAdventure03-使用碰撞体&触发器实现世界交互
2022-08-01 网工进阶(二十四) STP进阶知识
day16--抓包工具Charles的使用
【一起学Rust | 进阶篇 | RMQTT库】RMQTT消息服务器——安装与集群配置
TensorFlow 2.9的零零碎碎(一)
AFNetworking概述和4.0的实践
[Learn Rust together | Advanced articles | RMQTT library] RMQTT message server - installation and cluster configuration
本地生活商家如何通过短视频赛道,提升销量曝光量?
随机推荐
如何远程调试对方的H5页面
winget包管理器
短视频同城流量宣传小魔推有何优势?如何给实体商家带来销量?
day16--抓包工具Charles的使用
NaiveUI中看起来没啥用的组件(文字渐变)实现原来这么简单
DAY26:GetShell专题
Introduction to the delta method
问下cdc mysql to doris.不显示具体行数,怎么办?
本地生活商家如何通过短视频赛道,提升销量曝光量?
Ask next CDC mysql to Doris. Don't show the specific number of lines, how to do?
基于sklearn的决策树应用实战
大佬们,请问一下,oraclecdc报错没有序列化,可是我看源码中的确是没有继承序列化的,是什么原因
Process management (dynamic)
DGIOT 30 million meters set pressure reading
The precise effect of network integration promotion outsourcing in the era of Internet of Things-Shenzhen Win-Win World News
第十六天&charles的基本操作
In the SQL SERVER database, if the data of the table is added, deleted, or modified, will the index of the table be recorded in the ldf log?
Guys, may I ask, the oraclecdc error report is not serialized, but I see that the source code does not inherit serialization, what is the reason?
qrcode-----生成二维码
Obtain - 65 [chances] : "soldiers, subtlety also - 7-36 meter reading - defeat