Vue中td标签不能使用v-for中的数据?

新手上路,请多包涵

<tbody>

            <tr v-for="item in books" > 
                <td >{{item.id}}</td>
                <td >{{item.name}}</td>
                <td >{{item.date}}</td>
                <td >{{item.price}}</td>
                <td>
                <button type="button">-</button>
                {{item.count}}
                <button type="button">+</button>
                </td>
                <td><button type="button">操作</button></td>
            </tr>
            
            
        </tbody>
        
        
        const app  = new Vue({
            el:"#app",
            data:{
            
                books:[
                    {
                        id:1,
                        name:'(C++)',
                        date:'1998-5',
                        price:85.00,
                        count:1
                    },
                    {
                        id:2,
                        name:'(A++)',
                        date:'1998-5',
                        price:815.00,
                        count:1
                    },
                    {
                        id:3,
                        name:'(B++)',
                        date:'1998-5',
                        price:855.00,
                        count:1
                    },
                    {
                        id:4,
                        name:'(E++)',
                        date:'1998-5',
                        price:835.00,
                        count:1
                    },
                    {
                        id:5,
                        name:'(D++)',
                        date:'1998-5',
                        price:845.00,
                        count:1
                    },
                ]
            
            }
            
        })
阅读 2.5k
2 个回答

试试下面这样呢

   <template v-for="(item,index) in list">
     <tr>
        <template v-for="(sitem,sindex) in list1">
           <td></td>
        </template>
    </tr>
</template>
是不是没加<table></table>
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题