当前位置:   article > 正文

(vue)前端获取ip方法_前端获取ip地址

前端获取ip地址

(vue)前端获取ip方法


data(){
	return:{
		ipAddress: "",
	}
},

mounted() {
   this.getIPAddress();
 },

//获取ip
getIPAddress() {
  const url = "http://api.ipify.org?format=json";
  this.axios.get(url).then((response) => {
    this.ipAddress = response.data.ip;
    console.log(this.ipAddress);
  });
},
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18

解决参考:https://www.fke6.com/html/78898.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/349421
推荐阅读
相关标签
  

闽ICP备14008679号