1.此问题是根据网易云API调取到接口数据中的地址数据,从而对这个地址数据进行本地邮编json对照获取到对应得地址。
代码实现:
//调用接口
async Getdata(){
let uid=sessionStorage.getItem("id")
//该地方为获取照片地址,非本问题
const res=await getheadphoto(uid)
const photo=res.data.profile.avatarUrl
this.photo=photo
//从接口获取邮编地址
const address=res.data.profile.city
//获取到address解析成地址
for (let i = 0; i < map.length; i++) {
for(let j=0;j<map[i].citys.length;j++){
if(map[i].pid==address){
this.addressName=map[i].pname
}else if(map[i].citys[j].cid==address){
this.addressName=map[i].citys[j].cname
}
}
map.js文件会在后面分享出来