index.vue
1.4 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
56
57
58
59
60
61
62
63
64
65
66
67
68
<template lang="html">
<div class="tab-wrapper">
<div class="tab-content">
<tab bar-active-color="#8da9cf" :custom-bar-width="getBarWidth">
<tab-item active-class="active" v-for="(item, index) in list" :key="index" :class="{'vux-1px-r': index+1!==list.length}" :selected="default_selected === item" @on-item-click="onItemClick">{{item}}</tab-item>
</tab>
</div>
</div>
</template>
<script>
/**
* [参考用法 vux tab 组件]
*
* [list tab 显示名称]
* @type {Array}
*
* [default_selected tab 默认显示名称]
* @type {String}
*
* [on-item-click 点击回调返回 index]
*/
import { Tab, TabItem } from 'vux'
export default {
components: { Tab, TabItem },
props: ['list', 'default_selected'],
data () {
return {
getBarWidth: function (index) {
return (index + 1) * 40 + 'px'
}
}
},
methods: {
onItemClick (index) {
this.$emit('on-item-click', index)
}
}
}
</script>
<style lang="less" scoped>
@import '~vux/src/styles/1px.less';
@import '~vux/src/styles/center.less';
.vux-tab .vux-tab-item {
background: none;
}
.vux-1px-r:after {
height: 50%;
top: 30%;
}
.active {
color: #8da9cf !important;
border-color: #8da9cf!important;
}
.tab-wrapper {
padding: 1rem 1rem 0 1rem;
.tab-content {
border-top: 1px solid #dddddf;
border-left: 1px solid #dddddf;
border-right: 1px solid #dddddf;
}
}
</style>