在index.html中
<script src="https://pv.sohu.com/cityjson?ie=utf-8"></script>
在想获取ip的页面中
var Ip=returnCitySN[‘cip‘]
var cityname=returnCitySN[‘cname‘]
localStorage.setItem(‘Ip‘, Ip)
console.log(localStorage.getItem(‘Ip‘, Ip))
localStorage.setItem(‘cityname‘, cityname)
console.log(localStorage.getItem(‘cityname‘, cityname))
原文:https://www.cnblogs.com/cwl1025/p/14248306.html