我定义了一个myCollection.json文件
{
"collection":[
{
"user_name":"超级无敌abc",
"user_image_URL":"../assets/myCollection/user1.jpg",
"goods_image_URL":[
"../assets/myCollection/user1.1.jpg",
"../assets/myCollection/user1.2.jpg",
"../assets/myCollection/user1.3.jpg",
"../assets/myCollection/user1.4.jpg",
],
"goods_price":"1000",
"title":"跳楼清仓大甩卖",
"collect_state":true
},
{
"user_name":"我的名字就是无敌无敌无敌无敌无敌长",
"user_image_URL":"../assets/myCollection/user2.jpg",
"goods_image_URL":[
"../assets/myCollection/user2.1.jpg",
],
"goods_price":"24.5",
"title":"大学物理",
"collect_state":true
},
{
"user_name":"短",
"user_image_URL":"../assets/myCollection/user3.jpg",
"goods_image_URL":[
],
"goods_price":"50",
"title":"辣鸡Java低价出售",
"collect_state":true
}
]
}
然后我用axios获取json文件
this.$http.get('http://localhost:8081/static/json/myCollection.json').then(
function(response){
console.log(response.data);
},
function(response){
alert("连接json文件失败");
});//axio
如果是console.log(response.data);可以打印出json文件,可是console.log(response.data.collection);的话就会输出undefined。请问要怎么解决