【发布时间】:2018-05-20 23:15:28
【问题描述】:
我正在尝试将 v-for 与用于查询 Instagram 的 API 的 mount() 一起使用,以便显示来自用户页面的缩略图。我可以成功地将正确的数据记录到控制台,但由于某种原因,v-for 没有显示返回数据中的任何内容。
这是我的组件
<template>
<div class="container">
<div class="row -border-top">
<div v-for="(post, index) in posts" :key="index">
<img v-bind:src="post.images.thumbnail.url">
</div>
</div>
</div>
</template>
<script>
export default {
data: function() {
return {
posts: ''
}
},
mounted: function() {
$.get( "https://api.instagram.com/v1/users/self/media/recent/?access_token=[token]", function( data ) {
console.log(data.data); // works
this.posts = data.data;
});
}
}
</script>
任何帮助将不胜感激。
【问题讨论】: