forked from youzan/vant
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
38 lines (33 loc) · 850 Bytes
/
index.js
File metadata and controls
38 lines (33 loc) · 850 Bytes
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
import { createNamespace } from '../utils';
import { ParentMixin } from '../mixins/relation';
import { BORDER_TOP_BOTTOM } from '../utils/constant';
const [createComponent, bem] = createNamespace('collapse');
export default createComponent({
mixins: [ParentMixin('vanCollapse')],
props: {
accordion: Boolean,
value: [String, Number, Array],
border: {
type: Boolean,
default: true
}
},
methods: {
switch(name, expanded) {
if (!this.accordion) {
name = expanded
? this.value.concat(name)
: this.value.filter(activeName => activeName !== name);
}
this.$emit('change', name);
this.$emit('input', name);
}
},
render() {
return (
<div class={[bem(), { [BORDER_TOP_BOTTOM]: this.border }]}>
{this.slots()}
</div>
);
}
});