Skip to content

建议 Form 组件 提供类似 labelWidth API 或优化 labelCol 和 wrapperCol #450

Open
@EryouHao

Description

@EryouHao
  • I have searched the issues of this repository and believe that this is not a duplicate.

What problem does this feature solve?

之前使用 element 等 组件库的时候,发现 labelWidth 这个属性体验舒适,自己写组件库的时候也发现这个属性提供继承和 item 优先级更高的 API 蛮好的。
我目前能想到的是因为 ant design react 的没有实现,然后 vue 的为了保持 api 一致所以也没有提供😂

说一个技术实现上的小点,当然您估计更清楚,用 provide 和 inject 可以很方便地实现这种 API。

当使用 labelCol 和 wrapperCol 进行表单布局的时候,发现了两个不适:

  1. 表单过多时,可以说是两个及以上时,就发现出现重复代码,如果更多时,不适感更强,虽然可以通过抽象具体代码或通过 for 循环做一些代码瘦身。
  2. 使用这两个属性布局时,当页面宽度动态改变时,有时会发生 label 被表单空间遮盖问题,label没有自动换行(这个应该可以通过 css 解决,或通过组件库种的其他 API 解决,没有详细了解)

另外,一般情况下表单元素都是相同的 labelWidth 以保持布局对齐,所以 父组件(Form)提供控制 (Form.Item)的布局能力个人觉得蛮好的。

What does the proposed API look like?

建议提供 Form 直接管理表单布局的能力

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions