美文网首页
Vue代码 1

Vue代码 1

作者: _____西班木有蛀牙 | 来源:发表于2018-05-10 09:46 被阅读9次

效果:


表格渲染

代码:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title></title>
    <link href="https://cdn.bootcss.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet">
    <style>
        html {
            font-size: .9em;
        }

        .table td {
            vertical-align: middle;
        }

        .adv-images {
            object-fit: cover;
        }
    </style>
</head>

<body>
    <div class="container pt-5" id="app">
        <table class="table table-striped table-bordered table-hover table-sm text-center">
            <thead>
                <tr>
                    <th>排序号</th>
                    <th>图片</th>
                    <th>名称</th>
                    <th>状态</th>
                    <th>跳转地址</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                <tr v-for='item in tableData'>
                    <td>{{item.sort}}</td>
                    <td>
                        <img :src="'https://abc.yongweisoft.cn/Application/Public' + item.image" class="rounded adv-images" width="80" height="80"
                            alt="">
                    </td>
                    <td>{{item.name}}</td>
                    <td>
                        <span class="text-success" v-if='item.state == 1'>已启用</span>
                        <span class="text-danger" v-if='item.state == 0'>已禁用</span>
                    </td>
                    <td>
                        <span class="badge badge-secondary" v-if='item.status == 0'>不跳转</span>
                        <span class="badge badge-success" v-else-if='item.status == 1'>路径</span>
                        <span class="badge badge-info" v-else-if='item.status == 2'>指定内容</span>
                    </td>
                    <td>
                        <button type="button" @click='showAlert(item.id)' class="btn btn-primary btn-sm">操作按钮</button>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
    <script src="https://cdn.bootcss.com/vue/2.5.17-beta.0/vue.min.js"></script>
    <script>
        var app = new Vue({
            el: '#app',
            data: {
                tableData: [{ "id": "7", "image": "/upload/headImg/201803131315266038.jpg", "name": "12", "status": "0", "url": "", "content": "", "sort": "022", "state": "0" }, { "id": "5", "image": "/upload/headImg/201803131315428439.jpg", "name": "222222", "status": "2", "url": "", "content": "容内容内容", "sort": "12", "state": "1" }, { "id": "4", "image": "/upload/headImg/201803131315537248.jpg", "name": "333", "status": "1", "url": "http://www.baidu.com/", "content": "true", "sort": "true", "state": "1" }]
            },
            methods: {
                showAlert: function (id) {
                    alert(id)
                }
            }
        })
    </script>
</body>

</html>

相关文章

网友评论

      本文标题:Vue代码 1

      本文链接:https://www.haomeiwen.com/subject/istzrftx.html