展示
js
Page({ /** * 页面的初始数据 */ data: { list:"" }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { wx.request({ url: ‘http://www.kedemo.com/api/list‘, success: (result) => { // console.log(result.data.data) this.setData({ list:result.data.data }) }, }) }, //详情 find(res){ let id = res.currentTarget.dataset.id wx.navigateTo({ url: ‘/pages/xiangqing/xiangqing?id=‘+id, }) },
wxml
<block wx:for="{{list}}" wx:key="key"> <!-- 新闻列表 --> <view class="recommend" bind:tap="find" data-id="{{item.id}}"> <!-- <navigator class="recommend-list" open-type="navigate" url="/pages/newsdetail/newsdetail?id=1"> --> <view class="recommend-list"> <view> <image src="{{item.file}}" /> </view> <view class="recommend-list-item"> <view class="recommend-list-item-title">{{item.title}}</view> <view class="recommend-list-item-desc">{{item.desc}}</view> <view class="recommend-list-item-date">2019-08-11</view> </view> <!-- </navigator> --> </view> </view> </block>
详情展示
Page({ /** * 页面的初始数据 */ data: { find:"" }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { console.log(options.id) wx.request({ url: ‘http://www.kedemo.com/api/finds‘, data: { id : options.id }, success: (result) => { console.log(result.data.data) this.setData({ find:result.data.data }) }, }) },
详情展示就酱~~~
<block wx:for="{{find}}" wx:key="keys">
<view> {{item.id}}</view>
<view> {{item.title}}</view>
<view> {{item.desc}}</view>
<image src="{{item.file}}"></image>
</block>