Antd Utils
Edit page
Getting StartedReadme
Select
Table
Utils

Enum 2 Options

请选择
import React, { FC } from 'react'
import { Select, Form } from 'antd'
import 'antd/dist/antd.css'
import { enum2Options } from 'antd-utils'
// notice: Don't use Number as index of the Enum, or the ts-lint would throw error
// (also numberic index will be filter out in enum2Options function)
enum ESelectOptions {
option0 = 0,
optionA = "a",
optionTest = "test",
// 0 = a , // sorry it's invalid
}
const options = enum2Options(ESelectOptions)
export const Enum2Options: FC = () => {
return (
<>
<Form>
<Form.Item name="name">
<Select>
{
(options || []).map((item: any) => (
<Select.Option key={item.value} value={item.value}>{item.label}</Select.Option>
))
}
</Select>
</Form.Item>
</Form>
</>
)
}