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
<template>
<div class="tab">
<div :class="{'li-parent':true,light:data.routerName === $store.state.nowTab}" :key="data.path" v-for="data in tabList">
<div class="tab-li" @click="toPath(data.routerName)">
{{data.value}}
</div>
<i class="iconfont icon-close-b close-btn" v-if="!data.delNo" @click="delPath(data)"></i>
</div>
</div>
</template>
<script>
export default {
name: "tab",
data () {
return {
tabList:this.$store.state.openedTab,
}
},
mounted:function(){
},
methods:{
toPath:function (name) {
this.$router.push({name:name})
},
delPath:function (data) {
let i = this.$store.state.openedTab.indexOf(data);
this.$store.state.openedTab.splice(i,1);
if(data.routerName === this.$store.state.nowTab){
this.$router.push({name:this.$store.state.openedTab[i-1].routerName})
}
}
}
}
</script>
<style scoped lang="less">
@import "../../util/public";
.tab{
background: #444;
padding: 0 5px;
position: relative;
box-shadow: 0 0 5px @bg-b;
.clear-both;
.li-parent{
float: left;
margin: 5px;
user-select:none;
transition: all .3s;
background: @gold-color;
cursor: pointer;
font-size: 14px;
border-radius: 3px;
position: relative;
&.light{
background: @gold-color-light;
}
.close-btn{
position: absolute;
top: -4px;
right: -4px;
transition: all .1s;
color: @secondary-font-color;
&:hover{
transform: scale(1.2,1.2);
color: red;
}
}
.tab-li{
padding: 5px 10px 5px 10px;
}
}
}
</style>