I'm using mui select. I set the value [array type], but am unable to set the default value.
<select
defaultValue={[181, 182, 183]}
onChange={(e) => {
Setselectedverticle(e.target.value);
}}
>
<MenuItem key={0} value={0}>
Select the Verticle
</MenuItem>
{verticle.map((e, i) => {
return (
<MenuItem key={i} value={e.value}>
{e.label}
</MenuItem>
);
})}
</Select>;
I listed the sample data format below.
VERTICLE
[{key:184
label:"Entertainment"
value:[185, 186, 187, 188]},
{key:185
label:"Entertainment"
value:[185, 189, 189]}]
Use value instead of defaultvalue
<select
Value={[181, 182, 183]}
onChange={(e) => {
Setselectedverticle(e.target.value);
}}
>
<MenuItem key={0} value={0}>
Select the Verticle
</MenuItem>
{verticle.map((e, i) => {
return (
<MenuItem key={i} value={e.value}>
{e.label}
</MenuItem>
);
})}
</Select>;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.