--- order: 21 title: zh-CN: 扩展菜单 en-US: Custom dropdown --- ## zh-CN 使用 `open` 对下拉菜单进行自由扩展。如果希望点击自定义内容后关闭浮层,你需要使用受控模式自行控制([codesandbox](https://codesandbox.io/s/ji-ben-shi-yong-antd-4-21-7-forked-gnp4cy?file=/demo.js))。 ## en-US Customize the dropdown menu via `dropdownRender`. If you want to close the dropdown after clicking the custom content, you need to control `open` prop, here is an [codesandbox](https://codesandbox.io/s/ji-ben-shi-yong-antd-4-21-7-forked-gnp4cy?file=/demo.js). ```tsx import { PlusOutlined } from '@ant-design/icons'; import { Divider, Input, Select, Space, Button } from 'antd'; import type { InputRef } from 'antd'; import React, { useState, useRef } from 'react'; const { Option } = Select; let index = 0; const App: React.FC = () => { const [items, setItems] = useState(['jack', 'lucy']); const [name, setName] = useState(''); const inputRef = useRef(null); const onNameChange = (event: React.ChangeEvent) => { setName(event.target.value); }; const addItem = (e: React.MouseEvent) => { e.preventDefault(); setItems([...items, name || `New item ${index++}`]); setName(''); setTimeout(() => { inputRef.current?.focus(); }, 0); }; return ( )} > {items.map(item => ( ))} ); }; export default App; ```