A
A
Andrej Sharapov2019-06-28 21:23:21
Vue.js
Andrej Sharapov, 2019-06-28 21:23:21

Why doesn't nested v-for work?

Tell me what you missed? I do not understand why the list is not displayed. It looks like everything is connected.

new Vue({
  el: " #popup-modal",
  data() {
    return {
      listItem: [
        {
          title: 'text 1',
          object: [
            { name: '1', link: '#' },
            { name: '2', link: '#' },
            { name: '3', link: '#' },
          ]
        },
        {
          title: 'text 2',
          object: [
            { name: '1', link: '#' },
            { name: '2', link: '#' },
            { name: '3', link: '#' },
          ]
        }
      ]
    }
  },
  template: `
  <div id="popup-modal" class="hidden">
    <template v-for="item in listItem" :key="item.id">
    <div>
      <h3>{{ item.title }}</h3>
      <ul>
        <li v-for="{name, link} in listItem.object"><a :href="link" :title="name" target="_blank" rel="norefferer noopener">{{ name }}</a>
        </li>
      </ul>
    </div>
    </template>
  </div>
`
})

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2019-06-28
@Madeas

Should be item.objectinstead of listItem.object.
Why template? Remove. And move the v-for to a nested element.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question