我通过https://vk.com/dev/wall.get接收数据 在我这样解析它们之后:
<template>
<div class="walls">
<div class="loading" v-if="loading">
Loading...
</div>
<div v-if="error" class="error">
{{ error }}
</div>
<div class="album py-5 bg-light" v-if="walls">
<div class="container">
<div class="row">
<div class="col-md-4" v-for="wall in walls">
<div class="card mb-4 shadow-sm">
<img v-if="wall.copy_history" class="card-img-top" style="height: 225px; width: 100%; display: block;" src="">
<div class="card-body">
<a v-if="wall.attachments" :href="'https://vk.com/wall'+wall.owner_id +'_'+ wall.id">
<p class="card-text">{{ wall.text }}</p>
</a>
<a v-else-if="wall.copy_history" :href="'https://vk.com/wall'+wall.copy_history[0].owner_id +'_'+ wall.copy_history[0].id">
<p class="card-text">{{wall.copy_history[0].text}}</p>
</a>
<a v-else :href="'https://vk.com/wall'+wall.owner_id +'_'+ wall.id">
<p class="card-text">{{ wall.text }}</p>
</a>
<div class="d-flex justify-content-between align-items-center">
<small class="text-muted">{{ wall.id }}</small>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import axios from 'axios';
export default {
data() {
return {
loading: false,
walls: null,
error: null,
};
},
created() {
this.fetchData();
},
methods: {
fetchData() {
this.error = this.walls = null;
this.loading = true;
axios
.get('/api/walls')
.then(response => {
this.loading = false;
this.walls = response.data.items;
}).catch(error => {
this.loading = false;
this.error = error.response.data.message || error.message;
});
}
}
}
</script>
您需要从原始数据中获取图像(如果存在),如果当前帖子是转帖,如果当前帖子是原始帖子,请检查图像是否存在
附件如果存在,请将其删除。
我打破了我的头...告诉我..
添加照片,
then改为this.walls = response.data.items;添加之后
插入
我按照链接中的示例进行操作