用axios提取出本地的json文件,格式如下
"Merch": {
"hamburger": {
"1": {
"goodsImg": "http://7xjyw1.com1.z0.glb.clouddn.com/pos001.jpg",
"goodsName": "香辣鸡腿堡",
"price": 18
},
"2": {
"goodsImg": "http://7xjyw1.com1.z0.glb.clouddn.com/pos002.jpg",
"goodsName": "田园鸡腿堡",
"price": 15
}
},
"friedChicken": {
"3": {
"goodsImg": "http://7xjyw1.com1.z0.glb.clouddn.com/pos003.jpg",
"goodsName": "大包薯条",
"price": 18
},
"4": {
"goodsImg": "http://7xjyw1.com1.z0.glb.clouddn.com/pos002.jpg",
"goodsName": "脆皮炸鸡腿",
"price": 20
}
}
axios
.get("/static/data/Merch.json")
.then(response => {
let Merchs = response.data.Merch;
for (let key in Merchs) {
let eph = Merchs[key];
this.typeMerch.key=eph;
}
})
console.log(key),打印出来的是hamburger和frideChicken;
但是下面想添加进属性里,key却变成了字符串
为什么啊
有大大可以解释一下吗
桃花长相依
相关分类