forked from N3-components/N3-components
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathn3Panel.vue
executable file
·69 lines (66 loc) · 1.28 KB
/
n3Panel.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
57
58
59
60
61
62
63
64
65
66
67
68
69
<template>
<div class="{{prefixCls}}-panel {{prefixCls}}-panel-default">
<div class="{{prefixCls}}-panel-heading">
<h4 class="{{prefixCls}}-panel-title">
<a @click="toggleIsOpen()">
{{ header }}
</a>
</h4>
</div>
<div
class="{{prefixCls}}-panel-collapse"
v-el:panel
v-show="isOpen"
:transition="$parent.effect">
<div class="{{prefixCls}}-panel-body">
<slot></slot>
</div>
</div>
</div>
</template>
<script>
import type from './utils/type'
export default {
props: {
isOpen: {
type: Boolean,
default: false
},
header: {
type: String
},
index: {
},
onChange: {
type: Function
},
prefixCls: {
type: String,
default: 'n3'
}
},
data () {
return {
height: 0
}
},
methods: {
toggleIsOpen () {
this.isOpen = !this.isOpen
this.$dispatch('n3@paneltoggle', this)
if (type.isFunction(this.onChange)) {
this.onChange({
index: this.index,
header: this.header,
isOpen: this.isOpen
})
}
}
},
ready () {
const panel = this.$els.panel
panel.style.display = 'block'
if (!this.isOpen) panel.style.display = 'none'
}
}
</script>