js部分
onLoad: function () {
var that = this;
wx.request({
url: "http://192.168.17.132:8873/trpc?method=QueryItemInfo&service=trpc.Mobility.FMApp.FmAppService&radioId=1&userId=1",
method: 'get',
success: function (res) {
let radiolist = res.data.data
//重点是下面两句,核心代码. 你先把数据请求成功打印出来,如果能打印出来 就可以截取.
radiolist.endTime=radiolist.endTime.substring(10)
radiolist.startTime=radiolist.startTime.substring(10)
//这里可以用forEach() 来遍历,但是我们这里的radiolist 是对象,所以需要用对象转数组的方法. 最后一步存入radio 需要在上面的data 去定义.
that.setData({
radio: radiolist,
})
}
})
}
wxml 部分
<view class='title'>{{radio.itemName}}</view>
<view class='time'>{{radio.startTime}}-{{radio.endTime}} <view class='zhibo'>直播</view>