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

微信小程序跳转页面携带参数

时间:2020-10-15 02:47:29

相关推荐

微信小程序跳转页面携带参数

小程序跳转页面并携带参数,有两种情况,一是在wxml里通过navigator url跳转,一种是在js里通过点击事件跳转,下面案例为跳转详情页面

在wxml中:

<view class='wait-solve' wx:for="{{items}}" wx:key="items.name" wx:for-index="idx" wx:for-item="item"><navigator url='../../details/details?name={{item.name}}' class="weui-cell weui-cell_access" hover-class="weui-cell_active"><view class="weui-cell__bd" data-name="{{item.name}}" bindtap='jumpDetails'>{{item.value}}</view><view class="weui-cell__ft weui-cell__ft_in-access"></view></navigator></view>

在js中:

jumpDetails:function(e){var name=e.currentTarget.dataset.name;console.log(name)wx.navigateTo({url: "../details/details?name=" + name,})},

在跳转到详情页时获取携带过来的值:在onLoad中获取

data: {title: "详情",name: "", //跳转携带过来的参数}, onLoad: function(options) {this.setData({name: options.name})//这个时候就拿到传过来的name了console.log(this.data.name)}

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