微信小程序教程-调用服务器接口

论坛 期权论坛 脚本     
匿名技术用户   2021-1-16 08:13   230   0

微信小程序向后台发起请求非常简单,格式如下

    wx.request({
      url: 'https://jorian.api.cn/artilces',
      header: {
        'content-type': 'application/json'
      },
      method: 'GET',//get或者post
      data: { //请求参数,没有参数可以为空
        findtext: findtext //查询字符串
      },
      success: function (res) {
        console.log(res)//接口返回值
        that.setData({
          results: res.data.data
        })
      }
    })

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP