在材质UI的React select中更改禁用属性 [英] Change disable attribute in react select with material UI
本文介绍了在材质UI的React select中更改禁用属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用材质ui更改react应用程序中的select on button click中的disable属性我的按钮代码是:
I am trying to change disable attribute in select on button click in react application using material ui My button code is:
<AsistButton variant="outlined" color="primary" className={classes.button}>X</AsistButton>
,并且从选择中是:
<NativeSelect
value={person}
className={classes.margin}
onChange={handleChangeSelect}
input={<BootstrapInput name="person" id="person-customized-native-simple"/>}
disabled
>
<option value=""/>
<option value={10}>Peter</option>
<option value={20}>Alex</option>
<option value={30}>Jon</option>
</NativeSelect>
要实现该功能,我需要定义什么功能.
what function I need to define to achieve that.
推荐答案
您应在以下状态下编写计数器:
you should write a counter in state like:
state={disabled: false}
,点击后应将this.state.disabled设置为true.
and the on click should turn this.state.disabled to true.
在此之后,将NativeSelect组件中的设置禁用为
after that in the NativeSelect component set disabled to
disabled={this.state.disabled}
这篇关于在材质UI的React select中更改禁用属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文