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

当表单value都为空时, form getFieldsValue 方法会报错 #2708

Open
WynnLin opened this issue Nov 8, 2024 · 0 comments
Open

当表单value都为空时, form getFieldsValue 方法会报错 #2708

WynnLin opened this issue Nov 8, 2024 · 0 comments

Comments

@WynnLin
Copy link

WynnLin commented Nov 8, 2024

NutUI React 包名

@nutui/nutui-react-taro

NutUI React 版本号

2.7.0

平台

weapp

重现链接

重现步骤

useform.taro.ts

getFieldsValue = (nameList: NamePath[] | true): { [key: NamePath]: any } => {
    if (typeof nameList === 'boolean') {
      return JSON.parse(JSON.stringify(this.store))
    }
    const fieldsValue: { [key: NamePath]: any } = {}
    nameList.forEach((field) => {
      fieldsValue[field] = this.getFieldValue(field)
    })
    return fieldsValue
}

当 this.store 数据为空的时候 JSON.parse(JSON.stringify(this.store)) 会报错

是不是应该在组件库里给处理下

期望的结果是什么?

解决报错

实际的结果是什么?

现在会有error报错

环境信息

No response

其他补充信息

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant