带参数跳转小程序内其他页面,首先在wxml的标签中定义你的参数:
<view class="cu-item" wx:for="{{content}}" data-title="{{item.TITLE}}" data-content="{{item.CONTENT}}" data-createtime="{{item.createTime}}" bindtap="getContentDetail">
<view class="content" style="margin-left: -120rpx;">
<view class="text-grey text-cut">{{item.TITLE}}</view>
<view class="text-gray text-sm flex">
<text class="text-cut">{{item.CONTENT}}</text>
</view>
</view>
<view class="action">
<view class="text-grey text-xs" style="margin-left:-25rpx;">{{item.createTime}}</view>
</view>
</view>
点击按钮后出发的事件:
getContentDetail: function(e){
wx.navigateTo({
url: 'contentdetail?title=' + e.currentTarget.dataset.title + "&content=" + e.currentTarget.dataset.content + "&createtime=" + e.currentTarget.dataset.createtime,
})
}
跳转到想去的页面后,在onLoad中接收参数:
onLoad: function (options) {
var that = this
//获取被点击的建议的主键
that.setData({
title: options.title,
content: options.content,
createtime: options.createtime,
})
},