fix(components): 修复 Check 和 Radio 组件中隐藏输入值

- 在 Check 和 Radio 组件中,将 hidden 输入框的值从布尔型改为字符串
- 确保表单提交时,值为 'true' 或 'false',而不是 true 或 false
- 这个修改提高了与某些表单处理库的兼容性
This commit is contained in:
Vixalie
2025-08-12 21:40:23 +08:00
parent 12af84e680
commit 05aa4bc8e0
2 changed files with 2 additions and 2 deletions

View File

@@ -53,7 +53,7 @@ const Check: ParentComponent<CheckBoxProps> = (props) => {
<Dynamic component={CheckIcon[internalChecked() ? 1 : 0]} /> <Dynamic component={CheckIcon[internalChecked() ? 1 : 0]} />
<div>{mProps.children}</div> <div>{mProps.children}</div>
<Show when={isNotNil(mProps.name)}> <Show when={isNotNil(mProps.name)}>
<input type="hidden" name={mProps.name} value={internalChecked()} /> <input type="hidden" name={mProps.name} value={internalChecked() ? 'true' : 'false'} />
</Show> </Show>
</div> </div>
); );

View File

@@ -53,7 +53,7 @@ const Radio: ParentComponent<RadioProps> = (props) => {
<Dynamic component={RadioIcon[internalChecked() ? 1 : 0]} /> <Dynamic component={RadioIcon[internalChecked() ? 1 : 0]} />
<div>{mProps.children}</div> <div>{mProps.children}</div>
<Show when={isNotNil(mProps.name)}> <Show when={isNotNil(mProps.name)}>
<input type="hidden" name={mProps.name} value={internalChecked()} /> <input type="hidden" name={mProps.name} value={internalChecked() ? 'true' : 'false'} />
</Show> </Show>
</div> </div>
); );