feat: add Cascader component

This commit is contained in:
chenjiahan
2020-12-20 21:23:50 +08:00
committed by neverland
parent d0c981142a
commit 8180478213
8 changed files with 242 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
import { createNamespace } from '../utils';
import Popup from '../popup';
const [createComponent, bem] = createNamespace('cascader');
export default createComponent({
props: {
show: Boolean,
value: Array,
title: String,
options: Array,
placeholder: String,
confirmText: String,
activeColor: String,
},
methods: {
toggle(val) {
this.$emit('update:show', val);
},
confirm() {
this.toggle(false);
},
genHeader() {
const confirmText = this.confirmText || this.t('confirm');
return (
<div class={bem('header')}>
<h2 class={bem('title')}>{this.slots('title') || this.title}</h2>
<button type="button" class={bem('confirm')} onClick={this.confirm}>
{this.slots('confirm-text') || confirmText}
</button>
</div>
);
},
genTab() {},
},
render() {
return (
<Popup
round
value={this.show}
class={bem()}
position="bottom"
onInput={this.toggle}
>
{this.genHeader()}
{this.genTab()}
</Popup>
);
},
});