1、使用navigator实现页面跳转功能
index页面代码如下, open-type="redirect"或者直接添加redirect属性,表示在当前页打开;如果不加redirect就是跳转到新页面;两者都可以携带参数,多个参数用&拼接
<!--index.wxml-->
<viewclass="btn-area">
<navigator url="../navigator/navigator?title=我是navigate" >跳转到新页面</navigator>
<navigator url="../redirect/redirect?title=我是redirect" open-type="redirect" >在当前页打开</navigator>
</view>
2、参数解析
url : 当前小程序内的跳转链接
target :在哪个目标上发生跳转,默认当前小程序,默认值self
open-type : 跳转方式
navigate:对应 wx.navigateTo 或 wx.navigateToMiniProgram 的功能
redirect: 对应 wx.redirectTo 的功能
3、navigator页面处理
<!--navigator.wxml-->
<span>
<view> {{title}} </view></span>
<!--navigator.js-->
Page({
onLoad: function (options) {
this.setData({
title: options.title
})
}
})
4、redirect页面处理
<!--redirect.wxml-->
<span>
<view> {{title}} </view>
</span>
<!--redirect.js-->
Page({
onLoad: function (options) {
this.setData({
title: options.title
})
}
})
5、页面配置
<!--app.json-->
"pages": [
"pages/index/index",
"pages/logs/logs",
"pages/navigator/navigator",
"pages/redirect/redirect"
]
6、页面效果图
更多文章请关注公众号,谢谢
公众号回复:“navigator”,查看更多参数详解
联系方式:13128600812