在组件Vue中,我具有:
<a
href="#"
class="list-group-item list-group-item-action"
v-for="conversation in conversations"
v-bind:key="conversation.id"
>
<div class="d-flex w-100 justify-content-between">
<h5 class="mb-1">{{ conversation.tite }}</h5>
<small>{{ conversation.date }}</small>
</div>
<p
class="mb-1"
>Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.</p>
<small>Donec id elit non mi porta.</small>
</a>
在我的<script>
中,我有:
let conversations = [];
for (let i = 0; i < _.random(10, 20); i++) {
conversations.push({
id: i,
date: "3 days ago",
title: "My conversation",
tags: _.sampleSize(tags, 3)
});
// eslint-disable-next-line
console.log(conversations);
}
export default {
name: "ConversationsList",
data: () => {
return { conversations };
}
};
在我看来,它可以很好地循环,但是该组件未显示title
或date
答案 0 :(得分:1)
拼写错误,提示标题不正确。控制台应该有一些信息
<a
href="#"
class="list-group-item list-group-item-action"
v-for="conversation in conversations"
v-bind:key="conversation.id"
>
<div class="d-flex w-100 justify-content-between">
<h5 class="mb-1">{{ conversation.title }}</h5>
<small>{{ conversation.date }}</small>
</div>
<p
class="mb-1"
>Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.</p>
<small>Donec id elit non mi porta.</small>
</a>