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
79
80
81
82
83
84
| <template>
| <div class="h-list">
| <div class="h-list-content">
| <ul v-if="getDataLen">
| <li v-for="(item, key) in data" :key="key">
| <a href="javascript:;"
| @click="handlerClick(item)"
| :class="getClass(item)">{{item.text}}</a>
| </li>
| </ul>
| <div v-else class="h-list-no">暂无数据</div>
| </div>
| </div>
| </template>
| <script>
| export default {
| props: {
| data:{
| type: Array,
| default() {
| return []
| }
| },
| active: {
| type: [String, Number],
| default: -9990
| }
| },
| data() {
| return {
| acItem: this.active
| }
| },
| methods:{
| handlerClick: function(item) {
| if(this.acItem != item.id) {
| this.acItem = item.id;
| this.$emit('on-click', item);
| }
| },
| getClass: function(item) {
| var active = this.acItem;
| if(active == item.id) {
| active = true;
| }else {
| active = false;
| }
| // 定义样式
| var result = {
| active: active,
| };
| return result;
| }
| },
| computed: {
| getDataLen: function() {
| return this.data.length;
| },
|
| }
| }
| </script>
| <style scoped>
| .h-list-content li {
| list-style: none;
| }
| .h-list-content a{
| display: block;
| line-height: 32px;
| text-indent: 1em;
| color: rgb(90, 202, 250);
| }
| .h-list-content a:hover {
| background-color: rgb(59, 89, 141);
|
| }
| .h-list-content a.active {
| background-color: rgb(59, 89, 141)
| }
| .h-list-no {
| text-align: center;
| color: rgb(90, 202, 250);
| }
| </style>
|
|