当前位置:网站首页>【 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"
今天的小程序文章到这里就结束啦,如果觉得对您有帮助的话,可以关注牛牛接下来的文章,感谢您对支持,您的支持是我创作的最大动力!!!
债见~~
边栏推荐
- DGIOT 30 million meters set pressure reading
- J9数字论:关于DAO 特点的宏观分析
- 2022-08-01 网工进阶(二十三) VLAN高级技术-VLAN聚合、MUX VLAN
- IDLE development wordCount program (5)
- m.bjhjwy.com全面教学设备 类型包括: 教学仪器, 教学设备 ,
- 硬件工程师90天学习资料及笔记汇总
- Introduction to the delta method
- 协同工具满足70%-90%的工作需求,成为企业香饽饽
- SQL SERVER 数据库,表的数据发生增删改,该表的索引会在ldf日志中记录吗?
- js-----数组转换成树形结构
猜你喜欢
js reduce
【Unity入门计划】制作RubyAdventure03-使用碰撞体&触发器实现世界交互
Relaxation class: the boss will martial arts, who also can not hold up against!The charm of six sigma training
CV+Deep Learning——网络架构Pytorch复现系列——classification(三:MobileNet,ShuffleNet)
模糊查询除了like+ % 还能用什么方式
二叉树 --- 堆
[Learn Rust together | Advanced articles | RMQTT library] RMQTT message server - installation and cluster configuration
NPU architecture and force analysis
进程管理(动态的)
AFNetworking概述和4.0的实践
随机推荐
ARM Architecture 2: Processor Core and Assembly Instruction Set
iwemeta元宇宙:阿里首任COO:如何打造销售铁军
【OAuth2】二十、OAuth2扩展协议 PKCE
2022-08-01 网工进阶(二十三) VLAN高级技术-VLAN聚合、MUX VLAN
The precise effect of network integration promotion outsourcing in the era of Internet of Things-Shenzhen Win-Win World News
Uni applet Tencent map polygon background transparency
Add spark related dependencies and packaging plugins (sixth bullet)
本地生活商家如何通过短视频赛道,提升销量曝光量?
怎么使用【jmeter正则表达式提取器】解决返回值作参数的问题
How AliExpress sellers seize product search weight
【业务架构】价值链分析:提高客户价值和盈利能力
【微信小程序】一文读懂页面导航
组合数模板
每日一题,二叉树中增加一行
硬件工程师90天学习资料及笔记汇总20220730
90.(cesium之家)cesium高度监听事件
Rust learning: 6.4_ enumeration of composite types
MySQL的用户临时表与内部临时表
QT下载清华源配置
ARM结构体系3:ARM指令的寻址和异常中断处理