使用wx.getLocalIPAddress 获取手机本地IP地址,预览正常真机调试出错?

小程序 文章 2022-02-24 00:00 545 0 全屏看文

AI助手支持GPT4.0

使用wx.getLocalIPAddress 获取手机本地IP地址,预览正常真机调试出错?Use wx.getLocalIPAddress to get the local IP address of the mobile phone and preview the normal real device debugging error?

使用wx.getLocalIPAddress 获取手机本地IP地址,预览正常真机调试出错?

var app = getApp()

Page({

  data: {

    localIP: ''  // IP地址

  },

  onLoad: function (e) {  // 获取参数

    var that = this;

    wx.getLocalIPAddress({

      success (res) {

        //const localip = res.localip;

        that.setData({

          localIP: res.localip

        })

        }

    })

  }

})


“预览”显示192.168.1.3 很正常 。但是真机调试时,错误一大堆,哪个大侠帮忙分析一下。谢谢!

Var app = getapp () page ({data: {localip: '' / / IP address}, onload: function (E) {/ / get the parameter var that = this; Wx. Getlocalipaddress ({success (RES) {/ / const localip = res.localip; that. SetData ({localip: res.localip})})}) "Preview" displays 192.168.1.3, which is normal. But when debugging the real machine, there are a lot of errors. Which great Xia can help analyze it. thank you!

回答:

微盟:

你好 手机对应一下微信版本哈

tomheng:

是不是微信版本低,升级下微信试试

永世神话:文化操差
Mr.Zhao:

基础库 2.20.1 开始支持

-EOF-

AI助手支持GPT4.0