简体   繁体   English

内部 IP 与 Angular 11

[英]internal-ip with Angular 11

I tested the internal-ip npm package with Angular 13 and everything worked fine and I was able to get the correct IP address.我用 Angular 13 测试了internal-ip npm package,一切正常,我能够获得正确的 ZA412A3072BE46 地址。

Then I tried to integrated it into my Angular 11 project and it keeps giving me these error messages:然后我尝试将它集成到我的 Angular 11 项目中,它不断给我这些错误消息:

在此处输入图像描述

Try using below尝试使用下面

//declare this in the index.html as script src
https://api.ipify.org?format=jsonp&callback=**getMyIP**

//declare this in the index.html as script function
function getMyIP(json) {
  localStorage.setItem("<<your key>>", json.ip);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM