1 回答

TA贡献1797条经验 获得超4个赞
该库已经提供了禁用道具。您需要在代码中进行以下更改。
使构造函数具有默认值为false的isDisable状态
constructor(props){
super(props);
this.state={
isDisable:false
}
}
在onChange回调道具中添加一个函数
_checkMaximunSliderValue=(value)=>{
If(value==100){
this.setState({isDisable:true})
}
}
*“在禁用道具中设置this.state.isDisable **
<VerticalSlider
value={1}
disabled={this.state.isDisable}
min={0}
max={100}
onChange={(value: number) => {
this._checkMaximunSliderValue(value);
}}
onComplete={(value: number) => {
console.log("COMPLETE", value);
}}
width={50}
height={300}
step={1}
borderRadius={5}
minimumTrackTintColor={"gray"}
maximumTrackTintColor={"tomato"}
showBallIndicator
ballIndicatorColor={"gray"}
ballIndicatorTextColor={"white"}
/>;
添加回答
举报