drop-down.vue
1.8 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>
<view class="drop-down-list" v-if="isShow" :style="{ top: top + 'px' }">
<view class="san-jiao"></view>
<block v-for="(item,index) in selectList" :key="index">
<view class="city-items-names" @click="changeIm(item.deptname)" :class="item.isactive?'ac-tive':''">
{{item.deptname}}
</view>
</block>
</view>
</template>
<script>
export default {
props: {
show: {
type: Boolean,
default: false,
},
list: {
type: Array,
default () {
return []
}
},
active: {
type: String,
default: '',
},
top: {
type: String,
default: '40',
}
},
data() {
return {
isShow: this.show,
selectList: this.list,
isActive: this.active,
}
},
created() {
},
mounted() {
},
watch: {
list(val, oldval) {
this.selectList = val
},
show(val, oldval) {
this.isShow = val
},
active(val, oldval) {
this.isActive = val
},
},
computed: {
},
components: {
},
methods: {
changeIm(im) {
console.log(im, );
this.$emit('changedItem', im)
}
},
}
</script>
<style scoped lang="scss">
.drop-down-list {
width: 100%;
position: absolute;
top: 40px;
left: 0;
z-index: 2;
border-radius: 6px;
opacity: 1;
background: #fff;
box-shadow: -2px 3px 11px 0px rgba(58, 63, 71, 0.08);
.san-jiao {
border-width: 10px;
border-style: solid;
border-radius: 6px;
border-color: transparent transparent #fff transparent;
position: absolute;
top: -16px;
right: 30%;
z-index: 2;
}
.city-items-names {
width: 100%;
text-align: center;
line-height: 50px;
border-bottom: 1px solid #F2F5FA;
color: #000;
}
.ac-tive {
color: #5397FF;
}
}
</style>
<style>
</style>