插件用于微信小程序时,数入数字,不收回软键盘,组件数据没有更新,直接点击其他按钮时获取不到数字框的值,用户体验不太好,这个有办法优化么?

7***@qq.com
- 发布:2024-01-20 15:45
- 更新:2024-08-09 11:01
- 阅读:276
1 个回复
1***@qq.com - 精通uniapp,vue,react,node,go
修改uni-number-box源码,增加@input="_onInput"
<input :disabled="disabled" @input="_onInput" @focus="_onFocus" @blur="_onBlur" class="uni-numbox__value"
type="number" v-model="inputValue" :style="{background, color}" />
在methods定义这个方法,
_onInput(event) {
const value = event.target.value;
this.inputValue = value;
this.$emit("input", +this.inputValue);
this.$emit("update:modelValue", +this.inputValue);
this.$emit("change", +this.inputValue);
}
父组件调用@input
可以解决这个问题