Vue: v-for need empty tag for a group of element,something like ng-container with angular

Created on 7 Nov 2017  路  2Comments  路  Source: vuejs/vue

What problem does this feature solve?

Sometimes we don't really want a html element,for example in angular, we do loop like below,we don't want additional tag between ul and li,ng-cotainer solved the problem,is there any solution in Vue?

<ul class="book-list">
  <ng-container *ngFor="let book of books">
    <li class="book-item">{{ book.title }}</li>
    <li class="book-item">{{ book.author }}</li>
    <li class="book-item">{{ book.price }}</li>
  </ng-container>
</ul>

What does the proposed API look like?

Just like angular solution

Most helpful comment

Read the docs: https://vuejs.org/v2/guide/list.html#v-for-on-a-lt-template-gt

All 2 comments

Read the docs: https://vuejs.org/v2/guide/list.html#v-for-on-a-lt-template-gt

For everyone finding this answer, the Vue alternative for <ng-container> is <template>.

Was this page helpful?
0 / 5 - 0 ratings