onLoad: function (options) {
// var secondId = options.id;
var that = this;
wx.request({
url: ‘http://gank.io/api/xiandu/categories‘,
method: "get",
header: {
‘content-type‘: ‘application/json‘ // 默认值
},
success: function (res) {
console.log(res.data.results);
that.setData({
zhihu: res.data.results
//res代表success函数的事件对,data是固定的,stories是是上面json数据中stories
})
},
fail:function(res){
console.log(2)
}
})
}
结构
<block wx:for="{{zhihu}}">
<text style=‘display:block‘>{{item.name}}</text>
</block>
原文地址:https://www.cnblogs.com/liuliang389897172/p/9247251.html
时间: 2024-10-15 12:40:30