在 React Native 中禁用 Slider
Disable Slider once used in React Native
我正在使用 rn-vertical-slider,我必须在使用后禁用它,即一旦它被用户完成。我该怎么做???
这个库已经提供了禁用道具。您需要对代码进行以下更改。
使构造函数具有默认 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"}
/>;
我正在使用 rn-vertical-slider,我必须在使用后禁用它,即一旦它被用户完成。我该怎么做???
这个库已经提供了禁用道具。您需要对代码进行以下更改。
使构造函数具有默认 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"}
/>;