这是因为vue的模版中只有能一个根节点,所以在<template>中插入第二个元素就会报错

解决方案:

将<template>中的元素用一个大的<div>包起来,这样就可以在其中添加多个元素了,可以参考以下示例:

<template>
  <div >
    Hello Vue.js!{{message}}
    <span>{{message1}}</span>
    <span v-if="seen">你看到我啦!</span>
     <div >
       <ol>
         <li v-for="todo in todos"  v-bind:key="todo">
           {{ todo.text }}
         </li>
       </ol>
     </div>
  </div>
</template>

 

相关文章:

  • 2021-10-10
  • 2021-06-17
  • 2021-11-10
  • 2021-08-29
  • 2022-01-21
  • 2021-09-05
猜你喜欢
  • 2021-10-07
  • 2022-02-28
  • 2021-07-26
  • 2020-01-20
  • 2021-12-29
相关资源
相似解决方案