微信小程序开发(八)获取手机ip地址

// succ.wxml
<view>手机IP:{{motto.query}}</view>

// succ.js
var app = getApp()
Page({
  data: {
    motto: ''  // IP地址
  },
  onLoad: function (e) {  // 获取参数
    var that = this;
    wx.request({  // 获取ip
      url: 'http://ip-api.com/json',
      success: function (e) {
        that.setData({
          motto: e.data
        })
      }
    })
  }
})
原文地址:https://www.cnblogs.com/hudaxian/p/14814524.html