获取ip 地址
fetch('https://api.ipify.org?format=json') .then(response => response.json()) .then(json => console.log(json.ip) ) 获取 当前城市信息 var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200) { var response = JSON.parse(xhttp.responseText); console.log(response); } }; xhttp.open("GET", `http://ip-api.com/json/?lang=zh-CN`, true); xhttp.send(); 当前定位 : http://ip-api.com/json/?lang=zh-CN 指定ip : http://ip-api.com/json/8.8.8.8?lang=zh-CN 切换语言: lang=zh-CNhttps://ipapi.co/json/ 返回英文信息
https://api.vore.top/api/IPdata
标签:zh,CN,ip,前端,地址,xhttp,json,api From: https://www.cnblogs.com/cielw/p/18208775