我想在两个或其中一个输入为空时禁用按钮。顺便说一句,它是 Native Base 框架。
<View style={styles.personal} key={data}>
<Item floatingLabel>
<Label>Your name:</Label>
<Input />
</Item>
<Item floatingLabel style={{marginVertical: 20}}>
<Label>Your age:</Label>
<Input keyboardType="numeric"/>
</Item>
<Button style={{alignSelf: 'center'}} rounded disabled={false}
onPress={() => this.refs.swiper.scrollBy(1)}>
<Text style={{width: '70%', textAlign: 'center'}}>Next</Text>
</Button>
</View>
我尝试过的:
state = {
inputName: "",
inputAge: "",
}
<Input value={this.setState({inputName: value})}/>
<Input value={this.setState({inputAge: value})} keyboardType="numeric"/>
<Button style={{alignSelf: 'center'}} rounded
disabled={this.state.inputName==="" & this.state.inputAge==="" ? true:false }
onPress={() => this.refs.swiper.scrollBy(1)}>
<Text style={{width: '70%', textAlign: 'center'}}>Next</Text>
</Button>
变量值错误
沧海一幻觉
相关分类