pp8080

js  文件中 代码

 /**
 * 生命周期函数--监听页面加载
 */
  onLoad: function (options) {
    var thit = this
    wx.request({   //请求地址
      url: \'http://127.0.0.1:8000/ss/w/\',
      method: \'get\',    
     // data:{},//没有数据可以不写 
      header: {  //请求头
        \'content-type\': \'application/json\'
        // "Content-Type": "application/x-www-form-urlencoded"
      },

      //如果在sucess直接写this就变成了wx.request()的this了
      success: function (res) {
        // res.data相当于ajax里面的data,为后台返回的数据
        //打印后台返回的数据
        console.log(res.data.message)
        //直接把后台返回的数据 赋值给names 就可以直接调用names了
        thit.setData({ names: res.data.message })
      }
    })
  },

分类:

技术点:

相关文章:

  • 2021-12-28
  • 2021-06-06
  • 2021-09-01
  • 2021-12-18
  • 2021-12-18
  • 2021-12-28
  • 2021-10-16
猜你喜欢
  • 2021-09-28
  • 2021-12-18
  • 2022-12-23
  • 2021-04-23
  • 2021-05-14
  • 2021-12-28
  • 2022-01-04
相关资源
相似解决方案