1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > 微信小程序——获取所有资讯接口数据

微信小程序——获取所有资讯接口数据

时间:2023-07-26 19:56:41

相关推荐

微信小程序——获取所有资讯接口数据

首先获取数据把数据打印出来

接口文档

第一现在app.js 赋值 如:

app.js文件

App({globalData: {//资讯接口zixu_url: "http://192.168.1.107:8080/ls/api/client/info/list",//资讯id接口info_url:"http://192.168.1.107:8080/ls/api/client/info/id/",// 资讯详情id 的评论数据接口admin_comment:"http://192.168.1.107:8080/ls/api/client/comment/list/info/"}})

index.js文件

onLoad:function(){// 生命周期函数--监听页面加载 //'?page=0'+'&size=5' 展示前五条 var zix_data= app.globalData.zixu_url+'?page=0'+'&size=5';this.getMovieListData(zix_data)// console.log(postList)}getMovieListData: function (url) {var that = this;wx.request({url: url,method: 'post', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECTheader: {'content-type': 'application/json'},success: function (res) {that.setData({postList:res.data.objects,}););}},fail: function (error) {// failconsole.log(error)}})

}

index.wxml文件

<!--pages/index/index.wxml--><import src="zix-template/zix-template.wxml" /><!--<import src="/pages/posts/post-item/post-item-template.wxml" />--><scroll-view class='container' bindscrolltolower="lower" scroll-x='true' scroll-y='true'><block wx:for="{{postList}}" wx:for-item="item" ><!--//template--><view "><view class='zix_template'><image class='zix_img' src="{{coverImage}}"></image><text class='zix_tilte'>{{title}} </text></view></view></block></scroll-view>

本人只是为了个人技术回顾

第二节 如何下滑加载指定的数量数据

第三节 跳转详情页面的跳转

第四节 详情页面评论和 评论时间的转换遍历展示

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。