A way to render multiple root elements on VueJS with v-for directive

前端 未结 5 1697
轮回少年
轮回少年 2020-12-11 07:21

Right now, I\'m trying to make a website that shows recent news posts which is supplied my NodeJS API.

I\'ve tried the following:

HTML

5条回答
  •  暖寄归人
    2020-12-11 07:54

    Vue requires that there be a single root node. However, try changing your html to this:

    {{item.title}}

    {{item.msg}}

    This change allows for a single root node id="news" and yet still allows for rendering the lists of recent posts.

提交回复
热议问题