titleSubTitleCom.vue
1.06 KB
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
<template>
<div class="title-sub-title-com" ref="tabs" v-if="item && item.id && item.title" @click="changeTab(item)">
<div class="title-box" :class="{'active': item.id === activeId}">
<div class="title">
{{item.title}}
</div>
<div class="sub-title">
{{item.titles}}
</div>
</div>
<div class="line" v-if="line"></div>
</div>
</template>
<script>
export default {
data() {
return {
activeId: 0 // 活动项目id
};
},
props: ["item", "line"],
methods: {
/**
* 获取当前选中项目id
* @returns
*/
getActiveId() {
return this.activeId;
},
/**
* 设置活动项目id
* @param {Int} activeId [选中项目id]
*/
setActiveId(activeId) {
this.activeId = activeId;
},
/**
* 切换标签
* @param {object} item [对象]
*/
changeTab(item) {
this.$emit("changeTab", item);
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style rel="stylesheet/less" lang='less' scoped>
@import './titleSubTitleCom';
</style>