答案 0 :(得分:2)
答案 1 :(得分:1)
如您在documentation of Multiple Select in MUI中所见,您必须遍历每个选项并检查其是否为selected
。
const handleChangeMultiple = event => {
const { options } = event.target;
const value = [];
for (let i = 0, l = options.length; i < l; i += 1) {
if (options[i].selected) {
value.push(options[i].value);
}
}
console.log(value); // selected options
};
答案 2 :(得分:1)
您需要为每个选项传递值。
<MenuItem value="Admin">Admin</MenuItem>
<MenuItem value="User1">User1</MenuItem>
<MenuItem value="User2">User2</MenuItem>