tabsCom.vue
857 Bytes
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
<template>
<div class="tabs-com">
<div class="box">
<div class="tab" :class="{'active': (index == active)}" :style="{'color': (index == active) ? item.titleColor : ''}" @click="change(item, index)">
<div class="title">{{item.title}}</div>
<div class="line" :style="{'backgroundColor': (index == active) ? item.titleColor : ''}"></div>
</div>
</div>
</div>
</template>
<script>
export default {
data() {
return {
};
},
props: ["item", "index", "active"],
methods: {
/**
* 切换tab事件
* @param {Object} item [对象数据]
* @param {Number} index [索引]
*/
change(item, index) {
this.$emit('change', item, index);
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style rel="stylesheet/less" lang='less' scoped>
@import './tabsCom';
</style>