v-for 列表渲染---表格的制作

15 篇文章 0 订阅
14 篇文章 2 订阅

v-for 指令根据一组数组的选项列表进行渲染

v-for="item in items"

items是一个数组,item是当前被遍历的数组元素。

<!DOCTYPE html>
<html>

    <head>
        <meta charset="UTF-8">
        <title></title>
        <link rel="stylesheet" href="styles/demo.css" />
    </head>

    <body>
        <div id="app">
            <table>
                <thead>
                    <tr>
                        <th>标题1</th>
                        <th>标题2</th>
                        <th>标题3</th>
                        <th>标题4</th>
                    </tr>
                </thead>
                <tbody>
                    <tr v-for="item in items">
                        <td>{{ item.ranking  }}</td>
                        <td>{{ item.point  }}</td>
                        <td>{{ item.number  }}</td>
                        <td>{{ item.sales_volume  }}</td>
                    </tr>
                </tbody>
            </table>
        </div>
    </body>
    <script src="js/vue.js"></script>
    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                 items:[{
                        ranking:'1',
                        point:'阿里巴巴',
                        number:'1000',
                        sales_volume:'2000'
                    },{
                        ranking:'2',
                        point:'阿里巴巴',
                        number:'1000',
                        sales_volume:'2000'
                    },{
                        ranking:'3',
                        point:'阿里巴巴',
                        number:'1000',
                        sales_volume:'2000'
                    },{
                        ranking:'4',
                        point:'阿里巴巴',
                        number:'1000',
                        sales_volume:'2000'
                    },{
                        ranking:'5',
                        point:'阿里巴巴',
                        number:'1000',
                        sales_volume:'2000'
                    }]
            }
        })
    </script>

</html>

效果图如下

这里写图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值