react-native-modalModal 组件
react-native-modal 是 React Native 的 <Modal> 组件。
使用示例:
'use strict'; var React = require('react-native'); var Modal = require('react-native-modal'); var { AppRegistry, StyleSheet, View, Text } = React; class App extends React.Component { constructor() { this.state = { isModalOpen: false }; } openModal() { this.setState({isModalOpen: true}); } closeModal() { this.setState({isModalOpen: false}); } render() { return ( <View style={styles.page}> <Text onPress={() => this.openModal()}> Open Modal. </Text> <Modal isVisible={this.state.isModalOpen} onClose={() => this.closeModal()}> <Text>Hello world!</Text> </Modal> </View> ); } } var styles = StyleSheet.create({ page: { flex: 1, position: 'absolute', bottom: 0, left: 0, right: 0, top: 0 } }); AppRegistry.registerComponent('App', () => App);
评论