mirror of
https://github.com/youzan/vant.git
synced 2025-10-19 01:54:48 +00:00
[new feature] add Collapse component (#674)
This commit is contained in:
41
packages/collapse/index.vue
Normal file
41
packages/collapse/index.vue
Normal file
@@ -0,0 +1,41 @@
|
||||
<template>
|
||||
<div class="van-collapse van-hairline--top-bottom">
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { create } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-collapse',
|
||||
|
||||
model: {
|
||||
prop: 'activeNames'
|
||||
},
|
||||
|
||||
props: {
|
||||
accordion: Boolean,
|
||||
activeNames: [String, Number, Array]
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
items: []
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
switch(name, expanded) {
|
||||
const { activeNames } = this;
|
||||
if (!this.accordion) {
|
||||
name = expanded
|
||||
? activeNames.concat(name)
|
||||
: activeNames.filter(activeName => activeName !== name);
|
||||
}
|
||||
this.$emit('change', name);
|
||||
this.$emit('input', name);
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
Reference in New Issue
Block a user