返回顶部

antD——报错:模块 ""antd/es/checkbox/Group"" 没有导出的成员 "CheckboxValueType"。你是想改用 "import CheckboxValueType from "antd/es/checkbox/Group"" 吗?

参考:

1. https://github.com/ant-design/ant-design/issues/50000  import type { CheckboxValueType } from 'antd/es/checkbox/Group' 失效 #50000

2. https://github.com/ant-design/ant-design/pull/49073  fix: fix Checkbox.Group type #49073

3. https://ant-design.antgroup.com/docs/blog/type-util-cn  antd 里常用的 TypeScript 工具方法

 

我的问题

引入CheckboxValueType,报错:模块 ""antd/es/checkbox/Group"" 没有导出的成员 "CheckboxValueType"。你是想改用 "import CheckboxValueType from "antd/es/checkbox/Group"" 吗?

import type { CheckboxOptionType, CheckboxValueType } from 'antd/es/checkbox/Group'

 

原因

antd版本问题,我的antd版本是^5.20.0,^5.11.1、^5.15.1不会报错

 

解决方法

使用antd的工具类型 GetProp

import { Checkbox } from 'antd'

const CheckboxGroup = Checkbox.Group
type CheckboxValueType = GetProp<typeof Checkbox.Group, 'options'>[number]

 

 

 

 

posted @ 2024-09-05 11:15  前端-xyq  阅读(176)  评论(0)    收藏  举报