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);
        });
    },
相关推荐
开开心心就好33 分钟前
批量提取PDF中的图片,直接导出原图
前端·javascript·支持向量机·智能手机·pdf·html·启发式算法
默_笙5 小时前
🏛 给 AI 配一间办公室:Harness Engineering 六大模块与它的实现
前端·javascript
linux_cfan6 小时前
videojs v10 源代码系列解读:14 · 谓词守卫:在运行时安全地调用能力
前端·javascript·音视频
+VX:Fegn08958 小时前
计算机毕业设计|基于springboot + vue旅游管理系统(源码+数据库+文档)
java·开发语言·vue.js·spring boot·课程设计
雪芽蓝域zzs8 小时前
第 7 章:双 Y 轴组合图(柱状 + 折线,看板高频场景)
vue.js·echars
一 乐8 小时前
二手交易平台|基于springboot + vue二手交易平台(源码+数据库+文档)
java·数据库·vue.js·spring boot·小程序
天若有情6738 小时前
【纯前端小工具】公历生日转农历,批量查询每年农历生日对应的公历日期(GitHub Pages在线直接用)
前端·javascript·github pages·农历转换·lunisolar·网页小工具
vx-程序开发9 小时前
【计算机毕设】django校园跑腿服务系统83141
java·数据库·vue.js·spring boot·spring·elasticsearch·django
林语琛9 小时前
我写的 switch…break 被 Babel 偷偷吞了
前端·javascript·babel
liuchangng9 小时前
Jev 模型研究:从生成式大模型到决策式模型——System One、RLCD 校准与采用边界
java·javascript·人工智能·python·深度学习