|
@@ -1,13 +1,25 @@
|
|
|
<template>
|
|
|
<view class="m-input-view">
|
|
|
- <input :focus="focus" :type="inputType" :value="value" @input="onInput" class="m-input-input" :placeholder="placeholder"
|
|
|
- :password="type==='password'&&!showPassword" :maxlength="maxlength" @focus="onFocus" @blur="onBlur" />
|
|
|
+ <input
|
|
|
+ :focus="focus"
|
|
|
+ :type="inputType == 'password' ? 'text' : inputType"
|
|
|
+ :value="value"
|
|
|
+ @input="onInput"
|
|
|
+ class="m-input-input"
|
|
|
+ :placeholder="placeholder"
|
|
|
+ :password="type == 'password' && !showPassword"
|
|
|
+ :maxlength="maxlength"
|
|
|
+ @focus="onFocus"
|
|
|
+ @blur="onBlur" />
|
|
|
<!-- 优先显示密码可见按钮 -->
|
|
|
<view v-if="clearable&&!displayable&&value.length" class="m-input-icon">
|
|
|
<uni-icons color="#666666" type="clear" @click="clear"></uni-icons>
|
|
|
</view>
|
|
|
<view v-if="displayable" class="m-input-icon">
|
|
|
- <uni-icons :style="{color:showPassword?'#666666':'#cccccc'}" type="eye" @click="display"></uni-icons>
|
|
|
+ <uni-icons
|
|
|
+ :style="{color:showPassword?'#666666':'#cccccc'}"
|
|
|
+ type="eye"
|
|
|
+ @click.stop="showPassword = !showPassword"></uni-icons>
|
|
|
</view>
|
|
|
</view>
|
|
|
</template>
|
|
@@ -23,6 +35,7 @@
|
|
|
* 值
|
|
|
*/
|
|
|
value: String,
|
|
|
+ modelValue:String,
|
|
|
/**
|
|
|
* 占位符
|
|
|
*/
|
|
@@ -78,9 +91,7 @@
|
|
|
methods: {
|
|
|
clear() {
|
|
|
this.$emit('input', '')
|
|
|
- },
|
|
|
- display() {
|
|
|
- this.showPassword = !this.showPassword
|
|
|
+ this.$emit('update:modelValue','')
|
|
|
},
|
|
|
onFocus() {
|
|
|
this.isFocus = true
|
|
@@ -92,6 +103,7 @@
|
|
|
},
|
|
|
onInput(e) {
|
|
|
this.$emit('input', e.detail.value)
|
|
|
+ this.$emit('update:modelValue',e.detail.value)
|
|
|
}
|
|
|
}
|
|
|
}
|