提交 9c1b991c 编写于 作者: D DCloud_LXH

fix: clear.png、input-data clear-image 显示

上级 f6e3d819
...@@ -35,8 +35,7 @@ ...@@ -35,8 +35,7 @@
input: function (event : InputEvent) { input: function (event : InputEvent) {
// @ts-ignore // @ts-ignore
this.inputClearValue = event.detail.value this.inputClearValue = event.detail.value
// @ts-ignore if ((this.inputClearValue as string).length > 0) {
if (event.detail.value.length > 0) {
this.showClearIcon = true this.showClearIcon = true
} else { } else {
this.showClearIcon = false this.showClearIcon = false
...@@ -52,6 +51,20 @@ ...@@ -52,6 +51,20 @@
confirm(e : InputConfirmEvent) { confirm(e : InputConfirmEvent) {
// this.$emit('confirm', this.getValue(e.detail.value)) // this.$emit('confirm', this.getValue(e.detail.value))
}, },
blur() {
this.showClearIcon = false
},
focus() {
let inputValue = this.inputClearValue
if (typeof inputValue !== 'string') {
inputValue = inputValue.toString()
}
if ((inputValue as string).length > 0) {
this.showClearIcon = true
} else {
this.showClearIcon = false
}
},
getValue(value : any) : any { getValue(value : any) : any {
switch (this.type) { switch (this.type) {
case 'number': case 'number':
...@@ -70,9 +83,9 @@ ...@@ -70,9 +83,9 @@
<text class="uni-title-text"> {{title}} </text> <text class="uni-title-text"> {{title}} </text>
</view> </view>
</view> </view>
<view class="uni-input-wrapper input-wrapper uni-flex"> <view class="uni-input-wrapper input-wrapper">
<input class="uni-input" :type="inputType" :value="inputClearValue" :placeholder="title" @input="input" <input class="uni-input" :type="inputType" :value="inputClearValue" :placeholder="title" @input="input"
@confirm="confirm" /> @confirm="confirm" @blur="blur" @focus="focus"/>
<image class="input-wrapper_image" src="/static/icons/clear.png" v-if="showClearIcon" @click="clearIcon"> <image class="input-wrapper_image" src="/static/icons/clear.png" v-if="showClearIcon" @click="clearIcon">
</image> </image>
</view> </view>
...@@ -94,4 +107,4 @@ ...@@ -94,4 +107,4 @@
align-self: center; align-self: center;
margin-right: 10rpx; margin-right: 10rpx;
} }
</style> </style>
\ No newline at end of file
static/icons/clear.png

5.5 KB | W: | H:

static/icons/clear.png

5.8 KB | W: | H:

static/icons/clear.png
static/icons/clear.png
static/icons/clear.png
static/icons/clear.png
  • 2-up
  • Swipe
  • Onion skin
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册