Input add password prop
This commit is contained in:
parent
4ffcc60bf0
commit
8aa6a25014
1 changed files with 26 additions and 2 deletions
|
@ -7,6 +7,10 @@
|
||||||
<i class="ivu-icon ivu-icon-ios-search" :class="[prefixCls + '-icon', prefixCls + '-icon-normal', prefixCls + '-search-icon']" v-else-if="search && enterButton === false" @click="handleSearch"></i>
|
<i class="ivu-icon ivu-icon-ios-search" :class="[prefixCls + '-icon', prefixCls + '-icon-normal', prefixCls + '-search-icon']" v-else-if="search && enterButton === false" @click="handleSearch"></i>
|
||||||
<span class="ivu-input-suffix" v-else-if="showSuffix"><slot name="suffix"><i class="ivu-icon" :class="['ivu-icon-' + suffix]" v-if="suffix"></i></slot></span>
|
<span class="ivu-input-suffix" v-else-if="showSuffix"><slot name="suffix"><i class="ivu-icon" :class="['ivu-icon-' + suffix]" v-if="suffix"></i></slot></span>
|
||||||
<span class="ivu-input-word-count" v-else-if="showWordLimit">{{ textLength }}/{{ upperLimit }}</span>
|
<span class="ivu-input-word-count" v-else-if="showWordLimit">{{ textLength }}/{{ upperLimit }}</span>
|
||||||
|
<span class="ivu-input-suffix" v-else-if="password" @click="handleToggleShowPassword">
|
||||||
|
<i class="ivu-icon ivu-icon-ios-eye-off-outline" v-if="showPassword"></i>
|
||||||
|
<i class="ivu-icon ivu-icon-ios-eye-outline" v-else></i>
|
||||||
|
</span>
|
||||||
<transition name="fade">
|
<transition name="fade">
|
||||||
<i class="ivu-icon ivu-icon-ios-loading ivu-load-loop" :class="[prefixCls + '-icon', prefixCls + '-icon-validate']" v-if="!icon"></i>
|
<i class="ivu-icon ivu-icon-ios-loading ivu-load-loop" :class="[prefixCls + '-icon', prefixCls + '-icon-validate']" v-if="!icon"></i>
|
||||||
</transition>
|
</transition>
|
||||||
|
@ -15,7 +19,7 @@
|
||||||
:autocomplete="autocomplete"
|
:autocomplete="autocomplete"
|
||||||
:spellcheck="spellcheck"
|
:spellcheck="spellcheck"
|
||||||
ref="input"
|
ref="input"
|
||||||
:type="type"
|
:type="currentType"
|
||||||
:class="inputClasses"
|
:class="inputClasses"
|
||||||
:placeholder="placeholder"
|
:placeholder="placeholder"
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
|
@ -180,6 +184,11 @@
|
||||||
showWordLimit: {
|
showWordLimit: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
|
},
|
||||||
|
// 4.0.0
|
||||||
|
password: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
|
@ -188,10 +197,16 @@
|
||||||
prefixCls: prefixCls,
|
prefixCls: prefixCls,
|
||||||
slotReady: false,
|
slotReady: false,
|
||||||
textareaStyles: {},
|
textareaStyles: {},
|
||||||
isOnComposition: false
|
isOnComposition: false,
|
||||||
|
showPassword: false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
currentType () {
|
||||||
|
let type = this.type;
|
||||||
|
if (type === 'password' && this.password && this.showPassword) type = 'text';
|
||||||
|
return type;
|
||||||
|
},
|
||||||
prepend () {
|
prepend () {
|
||||||
let state = false;
|
let state = false;
|
||||||
if (this.type !== 'textarea') state = this.$slots.prepend !== undefined;
|
if (this.type !== 'textarea') state = this.$slots.prepend !== undefined;
|
||||||
|
@ -350,6 +365,15 @@
|
||||||
if (this.disabled) return false;
|
if (this.disabled) return false;
|
||||||
this.$refs.input.focus();
|
this.$refs.input.focus();
|
||||||
this.$emit('on-search', this.currentValue);
|
this.$emit('on-search', this.currentValue);
|
||||||
|
},
|
||||||
|
handleToggleShowPassword () {
|
||||||
|
if (this.disabled) return false;
|
||||||
|
this.showPassword = !this.showPassword;
|
||||||
|
this.focus();
|
||||||
|
const len = this.currentValue.length;
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$refs.input.setSelectionRange(len, len);
|
||||||
|
}, 0);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
|
Loading…
Add table
Reference in a new issue