Shamoon
Shamoon

Reputation: 43491

Why does my v-for loop not give me data in Vue.js?

In my component vue, I have:

      <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>

And in my <script>, I have:

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 };
  }
};

It loops fine in my view, but the component doesn't show the title or date

Upvotes: 0

Views: 67

Answers (1)

FLYFLU
FLYFLU

Reputation: 103

Spell Error,shoule title not tite .the console should have some info

  <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>

Upvotes: 1

Related Questions