微信小程序 帶參調用后台接口 循環渲染頁面 wx.request wx:for


test.js 文件里的onLoad

function getarticles(p,order,mythis) {
  wx.request({
    url: 'https://ganggouo.cn/index.php/Home/getarticles',    //后台接口地址
    method: 'post',  //post請求
    data: {
      p: p,
      order: order,
    },
    header: {
      'content-type': 'application/x-www-form-urlencoded'
    },
    success: function (res) {
      mythis.setData({
        Articlelist: res.data
      });
    },
    fail: function (res) {
      console.log(res);
    }
  });
};

 

test.html 頁面渲染

<view class='projectlist' >
  <view class='project'  wx:for="{{arrayProject}}"  wx:for-item="itemProjec" wx:key="id" data-datas="{{itemProjec}}" bindtap='projectDetail'>
      <view class='projectText'> {{itemProjec.gongchengmingcheng}} </view>
      <view class='projectleibie label'> {{arrayCategory[itemProjec.leixing].name}} </view>
      <view class='projectjiesuan label'> {{arraySchedule[itemProjec.jieduan].name}} </view>
      <view class='projectTime'> {{itemProjec.faburiqi}} </view>
  </view>
</view>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM