11

I am new to vue.js. I have a simple index.vue which tries to connect to contentful and display the entries from contentful. My code in index.vue looks like this:


<template>
  <div>
    <!-- render data of the person -->
    <h1>{{ person.fields.name }}</h1>
    <!-- render blog posts -->
    <ul>
      <li v-for="post in posts">
        {{ post.fields.title }}
      </li>
    </ul>
  </div>
</template>

<script>
  import {createClient} from '~/plugins/contentful.js'

  const client = createClient()

However when I try localhost:3000 from my browser...it comes back with the following error:


ERROR in ./pages/index.vue Module Error (from ./node_modules/eslint-loader/index.js):

C:\Users\admin\pdress\pages\index.vue 7:7 error Elements in iteration expect to have 'v-bind:key' directives vue/require-v-for-key

✖ 1 problem (1 error, 0 warnings)


I appreciate if someone can help me out to proceed further with my learning on vue.js please. Thanks in advance

user2368975
  • 309
  • 1
  • 4
  • 11
  • You can read more about why `key` is required in [the docs](https://vuejs.org/v2/guide/list.html#key) – ljubadr Jan 17 '19 at 03:04
  • Possible duplicate of [vue-language-server : Elements in iteration expect to have 'v-bind:key' directives](https://stackoverflow.com/questions/47608379/vue-language-server-elements-in-iteration-expect-to-have-v-bindkey-directiv) – krubo Oct 18 '19 at 13:47