<viewclass="flex-wrp"style="flex-direction:row;"wx:for="{{Industry}}"> <viewclass="flex-item bc_green"> ({{index}}){{item.date}} {{item.high}} {{item.low}} {{item.notice}} </view> </view> <viewclass="tip"hidden="{{isshow}}">數據加載完成</view>
js
// pages/list/list.js Page({ /** * 頁面的初始數據 */ data: { Industry:{}, isshow:true }, /** * 生命周期函數--監聽頁面加載 */ onLoad: function (res) { var that = this wx.request({ url: 'http://www.sojson.com/open/api/weather/json.shtml?city=杭州', header: { 'content-type': 'application/json' // 默認值 }, success: function (res) { console.log(res.data.data.forecast) that.setData({ Industry: res.data.data.forecast }) }, fail: function () { console.log("fail") }, complete: function () { that.setData({ isshow:false }) } }) }, /** * 生命周期函數--監聽頁面初次渲染完成 */ onReady: function () { }, /** * 生命周期函數--監聽頁面顯示 */ onShow: function () { }, /** * 生命周期函數--監聽頁面隱藏 */ onHide: function () { }, /** * 生命周期函數--監聽頁面卸載 */ onUnload: function () { }, /** * 頁面相關事件處理函數--監聽用戶下拉動作 */ onPullDownRefresh: function () { }, /** * 頁面上拉觸底事件的處理函數 */ onReachBottom: function () { }, /** * 用戶點擊右上角分享 */ onShareAppMessage: function () { }