我正在尝试显示 React Native 的 [DrawerLayoutAndroid][1]
组件:
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
'use strict'
import React, {
AppRegistry,
Component,
StyleSheet,
Text,
TextInput,
View,
ScrollView,
DrawerLayoutAndroid
} from 'react-native'
class Dictionary extends Component {
constructor(props) {
super(props)
this.state = {
movies: 'Test'
}
}
render() {
const navigationView = (
<View style={{flex: 1, backgroundColor: '#fff'}}>
<Text style={{margin: 10, fontSize: 15, textAlign: 'left'}}>Im in the Drawer!</Text>
</View>
)
return (
<ScrollView>
<DrawerLayoutAndroid
drawerWidth={300}
drawerPosition={DrawerLayoutAndroid.positions.Left}
renderNavigationView={() => navigationView}>
<View style={{flex: 1, alignItems: 'center'}}>
<Text style={{margin: 10, fontSize: 15, textAlign: 'right'}}>Hello</Text>
<Text style={{margin: 10, fontSize: 15, textAlign: 'right'}}>World!</Text>
</View>
</DrawerLayoutAndroid>
<View style={styles.parent}>
<Text>
Type something in English:
</Text>
<TextInput/>
<Text style={styles.germanLabel}>
Movies: { this.state.movies }
</Text>
</View>
</ScrollView>
)
}
}
const styles = StyleSheet.create({
parent: {
padding: 16
},
germanLabel: {
marginTop: 20,
fontWeight: 'bold'
},
germanWord: {
marginTop: 15,
fontSize: 30,
fontStyle: 'italic'
}
})
AppRegistry.registerComponent('Dictionary', () => Dictionary)
但是,应用程序不显示任何内容:
可能是什么原因? (也没有任何错误消息,看起来一切都编译得很好。)
最佳答案
尝试让你的DrawerLayoutAndroid作为根节点。文档中没有关于此的信息,但对我有帮助。这对您有帮助吗?
关于javascript - DrawerLayoutAndroid 没有显示任何内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35599241/