自定义下拉框
效果
index.tsx
import {
useState, useEffect} from 'react'
import {
observer} from 'mobx-react-lite'
import styles from './index.module.scss'
import recordStore from 'src/store/recordStore'
const DropDownBox: React.FC = props => {
const [dropDown, setDropDown] = useState(false)
const handleOpen = (e: any) => {
e.stopPropagation()
e.nativeEvent.stopImmediatePropagation()
setDropDown(!dropDown)
}
useEffect(() => {
document.body.addEventListener('click', () => {
setDropDown(false)
})
return () => {
document.body.removeEventListener('click', () => {
setDropDown(false)
})
}
}, [])
const selectMonth = (e: any