3lang3 / react-vant

React mobile UI Components base on Vant
https://react-vant.3lang.dev
MIT License
1.32k stars 189 forks source link

🐛 [Bug]: [DropdownMenu] 默认值 defaultValue #731

Open f3liiix opened 3 months ago

f3liiix commented 3 months ago

Which React Vant packages are impacted?

What version of React Vant are you using?

3.3.5

Reproduce live demo(codesandebox or stackblitz)?

No response

Descripition

默认值 defaultValue 依然有问题

const areas = [ { text: '武汉', value: 1 }, { text: '长沙', value: 2 }, { text: '成都', value: 3 }, ]

const [value, setValue] = useState<Record<string, string | number>>({})

`<DropdownMenu className='areas' value={value} defaultValue={{text: '武汉', value: 1}} onChange={v => setValue(v)}>

` 设置了默认值,但是依然显示 “请选择” ![screenshot-20240613-183038](https://github.com/3lang3/react-vant/assets/6493154/977fda61-6a0c-48b1-b618-c3cf4ee5ef1c)
nieyunliang commented 3 months ago

<DropdownMenu.Item name='value1' options={areas}/> </DropdownMenu> 把value1改成value即可