forked from N3-components/N3-components
-
Notifications
You must be signed in to change notification settings - Fork 0
/
n3Accordion.vue
executable file
·56 lines (52 loc) · 980 Bytes
/
n3Accordion.vue
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
<template>
<div class="{{prefixCls}}-panel-group">
<slot></slot>
</div>
</template>
<script>
import type from './utils/type'
export default {
props: {
oneAtATime: {
type: Boolean,
default: false
},
onChange: {
type: Function
},
effect: {
type: String,
default: 'collapse'
},
prefixCls: {
type: String,
default: 'n3'
}
},
events: {
'n3@paneltoggle' (child) {
let children = this.$children
let ret = []
if (this.oneAtATime) {
children.forEach((item) => {
if (child !== item) {
item.isOpen = false
}
})
}
children.forEach((item) => {
if (item.index) {
ret.push({
index: item.index,
isOpen: item.isOpen,
header: item.header
})
}
})
if (type.isFunction(this.onChange)) {
this.onChange(ret)
}
}
}
}
</script>