已写的代码:
let data = []
const res = axios.get('http://localhost:8080/area/city?level=1').then(res=>{
data=res.data.body
data.map((city)=>{
if(city.pinyin.slice(0,1).toUpperCase()==item.title){
item.items.push(city);
}
})
能看到获取到想要的数据:
但刷新页面后数据丢失了:
刷新后 重新请求 接口了吗?