HTML:
<view class="content" wx:for="{{oneList}}" wx:key = "id" bindtap="changeText">
<image src="../../images/piao1.jpeg"></image>
<view class="txt1">{{item.act_name}}</view>
<view>{{item.pro_name}}</view>
</view>
JS:
var app = getApp()
Page({
data: {
oneList: [{ //遍历数组,前台需要请求遍历的参数
id: '',
act_name: '',
pro_name: '',
}],
},
onLoad: function () {
var that = this;
var tokend = wx.getStorageSync('tokend') //token
console.log(tokend)
//刷新页面后得到已完成的数据
wx.request({
method: 'GET',
url: 'https://api?token=' + tokend,
header: { 'content-type': 'application/json' },
data: {},
success: function (res) { // success
console.log(res.data.data)
that.setData({ //将后台数值与前台数组匹配(集合)
oneList: res.data.data
})
}
});
},