[improvement] Collapse: jsx (#2501)

This commit is contained in:
neverland
2019-01-11 23:19:41 +08:00
committed by GitHub
parent 9e01b1ef16
commit 4b8bd8e9be
4 changed files with 66 additions and 77 deletions

View 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>;
}
});