微信小程序实现页面跳转传值以及获取值的方法分析微信小程序实现页面跳转传值以及获取值的方法分析
主要介绍了微信小程序实现页面跳转传值以及获取值的方法,结合实例形式总结分析了微信小程序页面跳转及传
值的常用操作技巧,需要的朋友可以参考下
本文实例讲述了微信小程序实现页面跳转传值以及获取值的方法。分享给大家供大家参考,具体如下:
在安卓中页面跳转传值都是通过bundle,现在研究一下小程序的列表跳转及页面传值。
my.wxml
<view class="container">
<view bindtap="bindViewTap" class="userinfo">
<image class="userinfo-avatar" src="{{userInfo.avatarUrl}}" background-size="cover"></image>
<text class="userinfo-nickname">{{userInfo.nickName}}</text>
</view>
<view class="info_list">
<block wx:for="{{userListInfo}}" >
<view class="weui_cell" data-index="{{item.index}}" id="{{item.index}}"
bindtap="userinfo_item">
<view class="weui_cell_hd">
<image src="{{item.icon}}"></image>
</view>
<view class="weui_cell_bd">
<view class="weui_cell_bd_p"> {{item.text}} </view>
</view>
<view wx:if="{{item.isunread}}" class="badge">{{item.unreadNum}}</view>
<view class="with_arrow"></view>
</view>
</block>
</view>
</view>
my.js
var app = getApp()
Page({
data: {
userInfo: {},
userListInfo: [{
icon: '../../images/iconfont-dingdan.png',
text: '我的订单',
isunread: true,
unreadNum: 2,
index:1
}, {
icon: '../../images/iconfont-kefu.png',
text: '联系客服',
index: 5
}, {
icon: '../../images/iconfont-help.png',
text: '常见问题',
index: 6
}]
},
onLoad: function () {
var that = this
//调用应用实例的方法获取全局数据
app.getUserInfo(function (userInfo) {
//更新数据
that.setData({
userInfo: userInfo
})
})
},
userinfo_item: function (e) {
var index = e.target.dataset.index;
console.log("----index----" + index)
console.log('-----id-----'
+ e.currentTarget.id)
var app = getApp();
//设置全局的请求访问传递的参数
app.requestId = e.currentTarget.id;
app.requestIndex = index;
}
})
评论0