小程序里面如何获取客户端ip

先找个API接口

ipD() {
	uni.request({
		url: 'https://xxx.com',
		success: (res) => {
			this.ip = res.data.ip
			this.ipData();
		}
	})
},
ipData() {
	const that = this;
	uni.request({
		url: 'https://xxx.com/' + this.ip,
		success: (res) => {
			console.log(res)
			that.city = res.data.city;
		}
	})
},

相关文章

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。