【发布时间】:2016-04-18 21:07:34
【问题描述】:
目前我正在借助一本书学习 React Native,其中解释了如何构建一个待办事项应用程序。但是由于此错误/错误,我无法继续。这发生在 IOS 中,不确定这是否也发生在 Android 上,因为我还没有设置我的 Android 模拟器只是 jet。
我的<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
}
});
我做了一些研究,发现了一些奇怪的事情;
- 我的两个输入都有宽度和高度
- 如果没有应用任何样式,输入也会消失
- 这只会发生在文本输入中,普通文本只会呈现。
一些见解会很棒,我认为这是一个错误,或者我只是忽略了一些东西..
【问题讨论】:
标签: javascript ios react-native react-jsx