diff --git a/packages/taro-runtime/src/dom/form.ts b/packages/taro-runtime/src/dom/form.ts index 0344830db021..3491a3aa11b3 100644 --- a/packages/taro-runtime/src/dom/form.ts +++ b/packages/taro-runtime/src/dom/form.ts @@ -13,9 +13,16 @@ export class FormElement extends TaroElement { } public dispatchEvent (event: TaroEvent) { - if ((event.type === 'input' || event.type === 'change') && event.mpEvent) { + if (event.mpEvent) { const val = event.mpEvent.detail.value - this.props.value = val as string + if (event.type === 'change') { + this.props.value = val as string + } else if (event.type === 'input') { + // Web 规范中表单组件的 value 应该跟着输入改变 + // 只是改 this.props.value 的话不会进行 setData,因此这里修改 this.value。 + // 只测试了 React、Vue、Vue3 input 组件的 onInput 事件,onChange 事件不确定有没有副作用,所以暂不修改。 + this.value = val as string + } } return super.dispatchEvent(event) }