From 448394ac4bc354c406b3107be43160aab8d0a8df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E7=81=8F?= Date: Sat, 14 Sep 2019 11:23:40 +0800 Subject: [PATCH] Update input.vue --- src/components/input/input.vue | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/components/input/input.vue b/src/components/input/input.vue index 0af953b7..d107830f 100644 --- a/src/components/input/input.vue +++ b/src/components/input/input.vue @@ -178,16 +178,32 @@ return { currentValue: this.value, prefixCls: prefixCls, - prepend: true, - append: true, slotReady: false, textareaStyles: {}, - showPrefix: false, - showSuffix: false, isOnComposition: false }; }, computed: { + prepend () { + let state = false; + if (this.type !== 'textarea') state = this.$slots.prepend !== undefined; + return state; + }, + append () { + let state = false; + if (this.type !== 'textarea') state = this.$slots.append !== undefined; + return state; + }, + showPrefix () { + let state = false; + if (this.type !== 'textarea') state = this.prefix !== '' || this.$slots.prefix !== undefined; + return state; + }, + showSuffix () { + let state = false; + if (this.type !== 'textarea') state = this.suffix !== '' || this.$slots.suffix !== undefined; + return state; + }, wrapClasses () { return [ `${prefixCls}-wrapper`, @@ -324,15 +340,6 @@ } }, mounted () { - if (this.type !== 'textarea') { - this.prepend = this.$slots.prepend !== undefined; - this.append = this.$slots.append !== undefined; - this.showPrefix = this.prefix !== '' || this.$slots.prefix !== undefined; - this.showSuffix = this.suffix !== '' || this.$slots.suffix !== undefined; - } else { - this.prepend = false; - this.append = false; - } this.slotReady = true; this.resizeTextarea(); }