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);
        });
    },
相关推荐
Discipline~Hai25 分钟前
Linux网络编程02-TCP协议
linux·网络·tcp/ip·嵌入式·linux网络编程
abc light1 小时前
Linux TCP网络
linux·网络·tcp/ip
独立开发之道1 小时前
Three.js 创建 VR 内容:四步把一个普通 3D 场景送进头显
javascript·3d·vr
zhao3266857511 小时前
动态IP怎么选购更合适?HTTP代理的使用指南有哪些关键要点
网络·tcp/ip·http
Coodor2 小时前
在前端如何转换IC卡卡号格式
前端·javascript·nfc·卡号格式
百慕大三角2 小时前
给 SPA 加页面切换动画:View Transitions API 从入门到实战
前端·javascript
Hilaku3 小时前
Bun 真的能取代 Node.js 吗?
前端·javascript·程序员
木公子4 小时前
Vue3源码精读04:Scheduler 调度器深度解析|异步批量更新与任务队列源码全解
前端·vue.js
开开心心就好4 小时前
手机悬屏翻译工具外语游戏漫画APP全覆盖
android·前端·javascript·python·游戏·pdf·html
光影少年4 小时前
react navite封装一个RN 通用按钮组件
前端·javascript·react native·react.js·前端框架