React Native - Label在Input的顶部



我找不到如何在输入的顶部添加标签。

<label > Constructor Name</label>
<TextInput style={styles.inputs}></TextInput>

当我这样做的时候,它不团结。在响应式样式中,标签和输入将彼此分开。我怎样才能把它们粘住呢?

您可以像这样为文本输入创建单独的组件发送占位符prop,它会在textput之前显示文本。

<View style={{}}>
<Text style={{color: 'white', fontWeight: 'bold', fontSize: 15, marginBottom: 5}}>{props.placeholder}</Text>
<TextInput
mode="outlined"
ref={textInput}
label={props.label || 'Email'}
secureTextEntry={secureTextEntry}
onChangeText={(text) => setText(text)}
returnKeyType={returnKeyType}
onSubmitEditing={onSubmitEditing}
multiline={multiline}
keyboardType={keyboardType}
value={text || value}
style={[
styles.inputStyle,
inputStyle,
]}
/>
</View>

最新更新