微信小程序request请求动态获取数据
生活随笔
收集整理的這篇文章主要介紹了
微信小程序request请求动态获取数据
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
微信小程序開發(fā)文檔鏈接
1 后臺代碼:
clickButton:function(){var that = this;wx.request({url: 'http://localhost:9096/admin.php/index/jj',method : 'POST',header: { 'content-type': 'application/x-www-form-urlencoded' },data : {},success: function (res) {//console.log(res.data);var t = this;var arr = new Array();arr = res.data;console.log(typeof (res.data));console.log(arr[0]);that.setData({user: res.data});}})this.setData({ msg: "Hello World" })}關(guān)于this.setData函數(shù)設(shè)置綁定數(shù)據(jù)的問題,如果 在request請求函數(shù)外部可以直接使用,如果在其內(nèi)部使用,會報異常。this不能在其直接使用需要在request請求函數(shù)外部
定義一個變量【名字隨意定義】,上面我定義的是一個that。
2 前臺代碼:
<view wx:for = "{{user}}">{{item.username}}</view>?
轉(zhuǎn)載于:https://www.cnblogs.com/xishaohui/p/9066126.html
總結(jié)
以上是生活随笔為你收集整理的微信小程序request请求动态获取数据的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Squid服务日志分析
- 下一篇: C艹 指针和const的关系和注意事项(