<Slider
style={{ width: 100 }}
value={isFinite(this.state.standArray[index]) ? this.state.standArray[index] : 10}
step={1}
minimumValue={0}
maximumValue={10}
onValueChange={(value) => {
this.setState((pre) => {
pre.standArray[index] = value
return {
standArray: pre.standArray
}
})
}}
onSlidingComplete={(value) => {
// item.score = value
let num = 0;
let countArry = [];
for (var j = 0; j < this.state.standArray.length; j++) {
num += this.state.standArray[j]
if (this.state.standArray[j] < this.state.passScore) {
countArry.push(this.state.standArray[j])
}
}
(countArry.length > 0) ?
this.setState({
totalScore: (num / this.state.standArray.length).toFixed(2) * 1,
orderContentShow: 'flex'
}) :
this.setState({
totalScore: (num / this.state.standArray.length).toFixed(2) * 1,
orderContentShow: 'none'
})
this.setState((pre) => {
pre.standArray[index] = value
return {
standArray: pre.standArray
}
})
}}
/>
RN循环赋值
最新推荐文章于 2022-03-02 14:16:00 发布