Skip to content

Commit

Permalink
fix(runtime): 修复 Vue2 Input 组件数据绑定问题,fix #9360 (#9468)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chen-jj authored Jun 8, 2021
1 parent b73d526 commit 6eadfbe
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/taro-runtime/src/dom/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 6eadfbe

Please sign in to comment.