当前我正在学习React Native,并在书籍的帮助下解释了如何构建应用程序。但是由于这个错误/错误,我无法继续。这发生在IOS,不知道这是否也发生在Android上,因为我没有设置我的Android模拟器只是喷气式飞机。React Native:TextInput在放入视图时消失
我的<View>
集装箱有两个<TextInputs>
,工作正常。 当我将两个输入封装到视图中时,它们只是“消失”。
这里是我的组件NoteScreen.js:
import React, {
Component,
StyleSheet,
TextInput,
View
} from 'react-native';
export default class NoteScreen extends Component {
render() {
return (
<View style={styles.container}>
<View style={styles.inputContainer}>
<TextInput
ref="title"
autoFocus={true}
autoCapitalize="sentences"
placeholder="Untitled"
style={styles.title}
onEndEditing={(text) => {this.refs.body.focus()}}
/>
</View>
<View style={styles.inputContainer}>
<TextInput
ref="body"
multiline={true}
placeholder="Start typing"
style={styles.body}
textAlignVertical="top"
underlineColorAndroid="transparent"
/>
</View>
</View>
);
}
}
var styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
marginTop: 64
},
textInput: {
color: '#ffffff',
flex: 1,
width: 60,
height: 60,
fontSize: 16
},
inputContainer: {
borderBottomColor: '#9E7CE3',
borderBottomWidth: 1,
flex: 1,
flexDirection: 'row',
marginBottom: 10
},
title: {
fontFamily: 'Overpass-Bold',
height: 40
},
body: {
fontFamily: 'Overpass-Bold',
flex: 1
}
});
我做了一些研究,发现了一些奇怪的事情;
- 我输入两者有一个宽度和高度
- 的输入也消失了,如果他们没有应用任何样式
- 这仅与文本输入发生,正常的文本只是渲染。
一些有识之士将是巨大的,我想这是一个错误,或者我只是俯瞰东西..
真棒,谢谢您的回答! Apperently我没有发布我的旧代码,我有styles.textInput和styles.body/title应用,但是,我没有把它们放在一个数组中。 –
不客气!我很高兴你解决了它!:) – Vikky
谢谢你好先生! – Trip