Vue代码-1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<!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>