作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的 react-native 应用程序中有一个 slider 组件,它使用最小值/最大值属性和 onValueChange 中的一些舍入很好地限制为 1-5 的离散值:
<View>
<Text style={styles.text} >
{this.state.value}
</Text>
<SliderIOS
ref='slider'
style={styles.slider}
value={1}
minimumValue={1}
maximumValue={5}
onValueChange={(value) => {
this.setState({
value: Math.round(value)
});
}}
/>
</View>
我想要的是 slider handle 按钮捕捉到离散位置 1、2、3、4、5,而不是沿着 slider 连续移动。提示表示赞赏!
最佳答案
供将来引用:SliderIOS 在此期间已被弃用,应该使用 Slider 组件。 <Slider>
带有一个步骤属性:
Step value of the slider. The value should be between 0 and (maximumValue - minimumValue). Default value is 0.
所以具体问题的解决方案就是简单地设置
<Slider
step={1}
...
/>
关于ios - 如何在 react-native (iOS) 中创建一个离散 slider ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32911434/
我是一名优秀的程序员,十分优秀!