100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > 微信小程序-页面跳转传递参数

微信小程序-页面跳转传递参数

时间:2020-12-13 07:44:51

相关推荐

微信小程序-页面跳转传递参数

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 :在哪个目标上发生跳转,默认当前小程序,默认值selfopen-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

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。