mirror of
https://github.com/youzan/vant.git
synced 2025-10-20 02:31:21 +00:00
[improvement] Collapse: jsx (#2501)
This commit is contained in:
32
packages/collapse/index.js
Normal file
32
packages/collapse/index.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import { use } from '../utils';
|
||||
|
||||
const [sfc, bem] = use('collapse');
|
||||
|
||||
export default sfc({
|
||||
props: {
|
||||
accordion: Boolean,
|
||||
value: [String, Number, Array]
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
items: []
|
||||
};
|
||||
},
|
||||
|
||||
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(h) {
|
||||
return <div class={[bem(), 'van-hairline--top-bottom']}>{this.$slots.default}</div>;
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user