每次我尝试运行此代码块时,它只会将a和b连接在一起。除+外,所有其他数学运算符均按预期工作。有什么办法可以停止/解决此问题?
export default class DataInput extends Component {
constructor(props) {
super(props);
this.state = {
a: 0,b: 0,};
}
handleCalculate = () => {
const { a,b} = this.state;
let average = (a + b)/2;
this.setState({ results: average });
};
render() {
return (
<View style={styles.DataInput}>
<View style={styles.value}>
<TextInput
placeholder="Bench Press"
onChangeText={a => this.setState({ a })}
keyboardType={"numeric"}
/>
</View>
<View style={styles.value}>
<TextInput
placeholder="Shoulder Press"
onChangeText={b => this.setState({ b })}
keyboardType={"numeric"}
/>
</View>
</View>