一个网络请求, 可以获取ip地址, 看下面代码

Page({
  data: {
    ip: ''
  },
  onLoad: function () {
    this.getapi();
    this.weatherweekday();
  },
  getapi:function(){
    var _this = this;
    // 获取IP地址
    wx.request({
      url: 'https://ip.tianqiapi.com/',
      data: {
      },
      method: 'POST',
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: function (res) {
        console.log(res);_this.setData({ip:res.data.ip});
      }
    });
  }
});

  

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。
扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄