pro-components
pro-components copied to clipboard
🧐[问题]: ProFormSelect组件 mode 设置为"tags"或"multiple"时,如何限制最大选择数量
🧐 问题描述
根据 Ant Design 的 Select 组件,有 maxCount 属性限制最大多选数量,但是在 ProFormSelect 中无法使用该属性。
💻 示例代码
<ProFormSelect
name="purifierBrand"
colProps={{ md: 12, xl: 4 }}
label="品牌"
request={getFilter.run}
mode="multiple"
debounceTime={300}
maxCount={2}
/>
<ProFormSelect
name="purifierBrand"
colProps={{ md: 12, xl: 4 }}
label="品牌"
request={getFilter.run}
mode="tags"
debounceTime={300}
fieldProps={{
maxCount: 2,
}}
/>
🚑 其他信息
上面两种方式均提示没有该属性
看看antd版本吧,antd版本可能不支持这个属性
<ProFormSelect
name="purifierBrand"
colProps={{ md: 12, xl: 4 }}
label="品牌"
request={getFilter.run}
mode="multiple"
debounceTime={300}
fieldProps={{
maxCount: 2,
}}
/>
maxTagCount亲测有效, 看了4.0 5.0的antd文档,都是maxTagCount这个字段,不知maxCount是哪里查到的
<ProFormSelect
name="purifierBrand2"
colProps={{ md: 12, xl: 4 }}
label="品牌"
options={[11,22,33,44,55,66,77]}
mode='tags'
debounceTime={300}
fieldProps={{
maxTagCount:2
}}
/>
maxTagCount亲测有效, 看了4.0 5.0的antd文档,都是maxTagCount这个字段,不知maxCount是哪里查到的
<ProFormSelect
name="purifierBrand2"
colProps={{ md: 12, xl: 4 }}
label="品牌"
options={[11,22,33,44,55,66,77]}
mode='tags'
debounceTime={300}
fieldProps={{
maxTagCount:2
}}
/>
maxTagCount亲测有效, 看了4.0 5.0的antd文档,都是maxTagCount这个字段,不知maxCount是哪里查到的
<ProFormSelect name="purifierBrand2" colProps={{ md: 12, xl: 4 }} label="品牌" options={[11,22,33,44,55,66,77]} mode='tags' debounceTime={300} fieldProps={{ maxTagCount:2 }} />
这两个不一样
看起来放到 fieldProps 里面应该就ok的
版本问题,ant design 5.13.1可以使用