scrollNav.vue
1.96 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<template>
<div class="scroll-nav" v-if="labels.length > 0">
<ScrollNavBar :current="this.list[current].title" :labels="labels" @change="changeHandler">
<span slot-scope="props">
{{props.txt}}
<span :ref="`getindex${props.txt}`" v-show="false">{{props.index}}</span>
</span>
</ScrollNavBar>
</div>
</template>
<script>
import { Style, ScrollNavBar } from 'cube-ui';
import queryString from 'query-string';
export default {
name: 'slide',
props: {
list: {
type: Array,
default: true
},
current: {
type: Number,
default: true
},
},
data() {
return {
index: 0,
labels: [],
};
},
components: {
Style,
ScrollNavBar
},
mounted() {
this.list.map((res) => {
this.labels.push(res.title);
});
},
created() {
},
methods: {
changeHandler(cur) {
let index = this.$refs[`getindex${cur}`].innerText;
let url = this.list[index].url.split('?');
let urlParams = queryString.parse(url[1]);
let params = urlParams;
params.isReset = true;
console.log(this.$parent);
this.$parent.$parent.$parent.fetchList && this.$parent.$parent.$parent.fetchList(params);
this.$emit('transfer', index);
}
}
};
</script>
<style lang="scss" scoped>
.scroll-nav {
padding: 0 24px;
}
/deep/ {
.cube-scroll-nav-bar {
background: none;
}
.cube-scroll-wrapper {
text-align: left;
}
.cube-scroll-content {
display: block;
}
.cube-scroll-nav-bar-item {
padding: 0 12px;
line-height: 52px;
font-size: 15px;
color: #555;
> span {
font-weight: 300;
}
}
.cube-scroll-nav-bar-item_active {
color: #000;
font-size: 16px;
position: relative;
> span {
font-weight: 500;
}
&:after {
content: "";
position: absolute;
left: 10px;
right: 10px;
bottom: 10px;
height: 3px;
background-color: #000;
}
}
}
</style>