一旦在React Native中使用,请禁用Slider

我正在使用rn-vertical-slider,一旦使用即必须由用户完成,我必须将其禁用。我怎样才能做到这一点???


鸿蒙传说
浏览 221回答 1
1回答

繁星coding

该库已经提供了禁用道具。您需要在代码中进行以下更改。使构造函数具有默认值为false的isDisable状态constructor(props){super(props);this.state={isDisable:false}}在onChange回调道具中添加一个函数_checkMaximunSliderValue=(value)=>{&nbsp;If(value==100){&nbsp;this.setState({isDisable:true})}}*“在禁用道具中设置this.state.isDisable **<VerticalSlider&nbsp; value={1}&nbsp; disabled={this.state.isDisable}&nbsp; min={0}&nbsp; max={100}&nbsp; onChange={(value: number) => {&nbsp; &nbsp; this._checkMaximunSliderValue(value);&nbsp; }}&nbsp; onComplete={(value: number) => {&nbsp; &nbsp; console.log("COMPLETE", value);&nbsp; }}&nbsp; width={50}&nbsp; height={300}&nbsp; step={1}&nbsp; borderRadius={5}&nbsp; minimumTrackTintColor={"gray"}&nbsp; maximumTrackTintColor={"tomato"}&nbsp; showBallIndicator&nbsp; ballIndicatorColor={"gray"}&nbsp; ballIndicatorTextColor={"white"}/>;
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript