fix: #17 VxeNumberInput 无法手动输入小数点 #18
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
在
input事件调用emitInputEvent函数设置当前输入的值,在这个函数中将当前输入的字符记录到了reactData.inputValue中。但由于props.immediate默认为true所以额外调用了一次emitModel(value, event),在emitModel函数中又设置了一次reactData.inputValue导致 BUG 触发。因为传递给emitModelvalue 值是一个已经被Number处理过的数值。如果输入了
3.那么Number处理过后就变成了3而不是3.或者3.0。这个 PR 做了什么?
由于
VxeNumberInput组件对外输出的数据是一个number而组件内部需要 string 来记录当前输入状态。所以reactData.inputValue就应该是input组件的输入值而不是最终输出结果。因此不应该在emitModel中直接设置它。该 PR 为
emitModel添加了writeToInput = true参数控制当前 emit 是否需要更新 input value。在emitInputEvent函数中并不需要更新它。