如果在ReactNative和NativeBase上使用TouchableOpacity,为什么图标消失了?

时间:2018-07-20 06:21:33

标签: javascript reactjs react-native native-base

我正在使用React Native和NativeBase。

我只是尝试在条目旁边显示一个图标,并在触发功能后向其中添加TouchableOpacity,但是该图标消失了

这是我的代码:

              <Item floatingLabel>
                  <Label>Password</Label>
                  <Input
                    autoCorrect={false}
                    autoCapitalize='none'
                    secureTextEntry={ this.state.securePass }
                    onChangeText = { value => this.updateInput('password', value)}
                    value = { this.state.form.password.value }  
                    type = { this.state.form.password.type }             
                  />
                   <TouchableOpacity>
                      <Icon name='eye'  type="FontAwesome" style={ styles.iconFont } />
                  </TouchableOpacity>
              </Item>

如果我将此代码放到nativeBase的Item之外,但不在其中:

               <TouchableOpacity>
                  <Icon name='eye'  type="FontAwesome" style={ styles.iconFont } />
              </TouchableOpacity>

希望您能帮上忙!

谢谢!

1 个答案:

答案 0 :(得分:0)

<View style={{flexDirection: 'row'}}>
<TouchableOpacity>
                      <Icon name='eye'  type="FontAwesome" style={ styles.iconFont } />
                  </TouchableOpacity>    
<Item floatingLabel>
                  <Label>Password</Label>
                  <Input
                    autoCorrect={false}
                    autoCapitalize='none'
                    secureTextEntry={ this.state.securePass }
                    onChangeText = { value => this.updateInput('password', value)}
                    value = { this.state.form.password.value }  
                    type = { this.state.form.password.type }             
                  />

              </Item>
</View>