-
Notifications
You must be signed in to change notification settings - Fork 280
fix(Form): Form 组件文档 demo 中 Switch 组件使用问题 #2774
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
Conversation
Walkthrough此拉取请求对 Changes
Possibly related PRs
Suggested labels
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
💤 Files with no reviewable changes (2)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (3)
src/packages/form/demos/h5/demo7.tsx (1)
61-63
: 正确添加了 Switch 组件所需的 valuePropName 属性
valuePropName="checked"
的添加解决了 Switch 组件在 Form 中的使用问题,确保了setFieldsValue
可以正确设置开关状态。建议在代码注释中添加说明,解释为什么 Switch 组件需要设置
valuePropName="checked"
,这样可以帮助开发者更好地理解这个属性的用途。+ {/* Switch 组件使用 checked 属性控制开关状态,因此需要设置 valuePropName="checked" */} <Form.Item label="Switch" name="switch" valuePropName="checked"> <Switch /> </Form.Item>
src/packages/form/demos/taro/demo7.tsx (2)
61-63
: 修复正确,建议补充注释说明
valuePropName="checked"
的添加解决了 Switch 组件在 Form 中的使用问题,确保了setFieldsValue
可以正确控制开关状态。建议添加示例注释说明这个重要属性的用途:
+ {/* Switch 组件使用 checked 属性控制状态,需要设置 valuePropName="checked" */} <Form.Item label="Switch" name="switch" valuePropName="checked"> <Switch /> </Form.Item>
Line range hint
38-134
: 建议为表单添加初始值示例为了使示例更完整,建议添加
initialValues
属性来展示如何设置表单的默认值,特别是 Switch 组件的默认状态。<Form style={{ '--nutui-form-item-label-width': '120px' }} + initialValues={{ + switch: true, // 设置 Switch 的默认值 + form_input: '默认输入值', + // 其他表单项的默认值... + }} footer={ // ... 现有代码 ... }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
src/packages/form/demos/h5/demo7.tsx
(1 hunks)src/packages/form/demos/taro/demo7.tsx
(1 hunks)
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## next #2774 +/- ##
=========================================
+ Coverage 0 84.07% +84.07%
=========================================
Files 0 217 +217
Lines 0 17830 +17830
Branches 0 2609 +2609
=========================================
+ Hits 0 14991 +14991
- Misses 0 2834 +2834
- Partials 0 5 +5 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
🤔 这个变动的性质是?
🔗 相关 Issue
💡 需求背景和解决方案
Form 文档中使用 Switch 组件时没有指定 valuePropName,这会导致通过 setFieldsValue 赋值不生效
☑️ 请求合并前的自查清单
Summary by CodeRabbit
Demo7
组件的开关输入中,添加了valuePropName="checked"
属性,以正确管理开关的状态。TextArea
组件的placeholder
处理逻辑,改为基于语言环境动态赋值。