vue页面中获取用户ip

javascript 复制代码
getIPAddress() {
      // 使用异步请求获取IP地址
      const url = 'https://api.ipify.org?format=json';
      fetch(url)
        .then(response => response.json())
        .then(data => {
          this.ipAddress = data.ip;
          console.log("本机ip地址",this.ipAddress);
        })
        .catch(error => {
          console.log('获取IP地址失败:', error);
        });
    },
相关推荐
heart000_11 分钟前
从零开始打造个人主页:HTML/CSS/JS实战教程
javascript·css·html
90后小陈老师1 小时前
3D个人简历网站 5.天空、鸟、飞机
前端·javascript·3d
chenbin___1 小时前
react native text 显示 三行 超出部分 中间使用省略号
javascript·react native·react.js
yezipi耶不耶3 小时前
用 Rust 带你了解 TCP 和 UDP
tcp/ip·rust·udp
漫路在线5 小时前
JS逆向-某易云音乐下载器
开发语言·javascript·爬虫·python
BillKu6 小时前
Vue3 Element Plus 对话框加载实现
javascript·vue.js·elementui
初遇你时动了情7 小时前
html js 原生实现web组件、web公共组件、template模版插槽
前端·javascript·html
前端小崔7 小时前
从零开始学习three.js(18):一文详解three.js中的着色器Shader
前端·javascript·学习·3d·webgl·数据可视化·着色器
运维@小兵8 小时前
vue配置子路由,实现点击左侧菜单,内容区域显示不同的内容
前端·javascript·vue.js
GISer_Jing9 小时前
[前端高频]数组转树、数组扁平化、深拷贝、JSON.stringify&JSON.parse等手撕
前端·javascript·json