在部分机型上确实有这样的问题。
可以暂时参考下面的代码暂时规避
<template>
<scroll-view style="padding-top:100px;" class="main" scroll-y>
<input v-model="input" placeholder="键盘完成按钮文字为搜索" confirm-type="search" onconfirm={this.onconfirm} />
<text>{input}</text>
<button @click="clean">清空333</button>
</scroll-view>
</template>
<script>
export default {
name: 'test',
install(){
this.i = 0
},
data() {
return {
input: ""
}
},
methods: {
onconfirm(e) {
api.alert({
msg: '搜索' + e.detail.value.trim()
});
},
clean() {
this.input = ' '.repeat(this.i++%2)
}
}
}
</script>
<style>
.main {
width: 100%;
height: 100%;
}
input {
margin: 8px;
width: auto;
}
</style>
其中,使用一个计数器 i 来主动形成 diff ,让 input 的 value 更新。
同时注意 ,获取值的时候,使用 trim() 来去除空白。 |