美文网首页
微信小程序系列-调用本地接口

微信小程序系列-调用本地接口

作者: 囝囝123 | 来源:发表于2019-04-23 11:49 被阅读0次

    1.首先打开不校验合法域名


    image.png

    2.在对应的js 页面的page 中定义方法

     /**
       * 页面方法
       */
      onTap:function(){
        var that = this;
        wx.request({
          url: 'http://localhost:8080/checkStuApi',
          data:{
            xm:'陈星鹏',
            grbsm:"G110106200403174",
            appCode: "hdxs",
            token:"36aea78b-c94d-4799-935b-91d74e01"
          },
          method:"post",//可以设置不同方式   如:get等
          header:{
            'content-type': 'application/x-www-form-urlencoded' 
          },
          success(res){
            console.log(res.data);
            that.setData({//给对应的模块赋值
              title:res.data.message
             }
            );
          }
        })
        
      },
    

    3.然后编译项目,创建点击事件调用创建的js返回页面
    也可以在控制台看见


    image.png

    最后进行业务处理;

    参考文档:
    https://developers.weixin.qq.com/miniprogram/dev/api/wx.request.html

    相关文章

      网友评论

          本文标题:微信小程序系列-调用本地接口

          本文链接:https://www.haomeiwen.com/subject/lxxvgqtx.html