如果我在React Native和Native Base中使用TouchableOpacity,为什么图标会消失?

问题描述 投票:1回答:1

我正在使用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>

我希望你能帮帮我!

谢谢!!

javascript reactjs react-native native-base
1个回答
1
投票
<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>
© www.soinside.com 2019 - 2024. All rights reserved.