Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(runtime): 修复 Vue2 Input 组件数据绑定问题,fix #9360 #9468

Merged
merged 1 commit into from
Jun 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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