小程序的后台数据 前端加载时页面展示


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>


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM