我想将Material UI自动完成组件中的多个选择限制为同一组中的选项.
I would like to limit multiple selections within the Material UI Autocomplete component to options within the same group.
有关未设置解决方案的问题的设置,请参见链接的沙箱. codesandbox.io/s/material-demo-7g4ed?file =/demo.js
See linked sandbox for a setup of the problem without an implemented solution. codesandbox.io/s/material-demo-7g4ed?file=/demo.js
例如,在上方的沙箱中,用户只能选择Apple或Amazon产品,而不能同时选择两者.
So, for example in the sandbox above the user should only be able to select Apple or Amazon products, not both.
任何帮助将不胜感激!
推荐答案假设您要将选择限制为3个,在代码中更新这两行
Suppose you would like to limit selections to 3, update those two lines in your code
freeSolo = {tags.length>3个?false:true}
getOptionDisabled = {(options)=>(tags.length> 3?true:false)}
更多推荐
如何将Material UI自动完成多项选择限制为一组
发布评论