From 77dda57e2105c675123333c0b9f099eafe9f6860 Mon Sep 17 00:00:00 2001 From: dolymood Date: Thu, 19 Apr 2018 14:15:14 +0800 Subject: [PATCH] select use $props & $events --- src/components/select/select.vue | 36 +++++++++++++------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/src/components/select/select.vue b/src/components/select/select.vue index 84ed87f9..c977ddfc 100644 --- a/src/components/select/select.vue +++ b/src/components/select/select.vue @@ -77,38 +77,30 @@ return index }, + selectedIndex() { + return this.valueIndex !== -1 ? [this.valueIndex] : [0] + }, selectedText() { return this.valueIndex !== -1 ? this.adaptOptions[0][this.valueIndex].text : '' - }, - txts() { - return { - title: this.title, - confirmTxt: this.confirmTxt, - cancelTxt: this.cancelTxt - } - } - }, - watch: { - txts() { - this.updatePicker() } }, created() { this.picker = this.$createPicker({ - title: this.title, - data: this.adaptOptions, - selectedIndex: this.valueIndex !== -1 ? [this.valueIndex] : [0], - cancelTxt: this.cancelTxt, - confirmTxt: this.confirmTxt, - onSelect: this.selectHandler, - onCancel: this.hided + $props: { + title: 'title', + data: 'adaptOptions', + selectedIndex: 'selectedIndex', + cancelTxt: 'cancelTxt', + confirmTxt: 'confirmTxt' + }, + $events: { + select: 'selectHandler', + cancel: this.hided + } }) this.autoPop && this.showPicker() }, methods: { - updatePicker() { - this.picker.$updateProps(this.txts) - }, showPicker() { if (this.disabled) { return -- GitLab