如何将Material UI自动完成多项选择限制为一组

编程入门 行业动态 更新时间:2024-10-10 05:17:09
本文介绍了如何将Material UI自动完成多项选择限制为一组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想将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自动完成多项选择限制为一组

本文发布于:2023-11-28 11:53:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1642298.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多项   如何将   自动完成   UI   Material

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!