我正在从一个api调用,其中的信息如下所示:
({"total_hits":187,"content":[{"id":"4659","title":"Idio Celebrates Gramercy...
以此类推。我正在尝试使用Vue访问帖子的标题,然后在面板中显示它们。到目前为止,我有:
<template>
<div class="wrapper">
<div class = "panel" >
<div class = "image" > {{info.content}} </div>
<div class = "title"> </div>
</div>
</div>
</template>
<script>
import axios from 'axios';
export default {
name: 'panel',
data(){
return{
info: []
}
},
created() {
axios.get('https://api.idio.co/1.0/content/.json?key=APIKEY&callback=')
.then(response => {
var obj = response.data;
this.info = obj;
})
.catch(error => {
console.log(error);
})
},
}
</script>
但是当我调用info.content时,它是未定义的,而{{info}}只会导致json文本变哑。同样,在信息中使用v-for =“ item”会为每个字符生成一个元素。如何正确访问JSON的元素,并遍历各个帖子?