uniapp如何获取IP地址
js获取
<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script> <script type="text/javascript"> console.log(returnCitySN["cip"]+','+returnCitySN["cname"]) </script>
uniapp获取
uni.request({ url:'http://pv.sohu.com/cityjson?ie=utf-8', method:'POST', success: (res) => { const reg = /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/; let ip = reg.exec(res.data); console.log(ip[0]); } })