解决方案一

v-for(v,k)括号后面这里要加空格,不能贴着in,否则会报错

 1 <body>
 2 
 3     <section >
 4         <table v-for='(item,index ) in monster'>
 5             <tr>
 6                 <th>名称</th>
 7             </tr>
 8             <tr>
 9                 <td>{{item}}</td>
10                 <td>{{item.name}}</td>
11                 <td>{{index}}</td>
12             </tr>
13            
14         </table>
15     </section>
16 
17     <script>
18         var app = new Vue({
19             el: '#app',
20             data: {
21                 monster: [
22                     { name: '独眼蝙蝠', lv: 1, hp: 100 },
23                     { name: '彭哚菇', lv: 3, hp: 300 }
24                 ]
25             },
26             methods: {},
27         })
28     </script>
29 </body>

 

 

解决方案二

v-for写的位置,出现了层级关系问题,修改v-for的位置可以解决

相关文章:

  • 2021-07-01
  • 2021-09-21
  • 2021-12-09
  • 2021-09-14
  • 2021-06-23
  • 2022-12-23
猜你喜欢
  • 2021-04-10
  • 2022-12-23
  • 2021-08-28
  • 2021-07-16
  • 2021-09-09
  • 2021-06-26
  • 2021-05-18
相关资源
相似解决方案