Modal 组件 react-native-modal

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/phj_88/article/details/82141755

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);

博主花大量时间和精力整理了大前端最新前端视频教程,省去大家找资源的时间

有兴趣的可以点击下方文字访问博主淘宝网(感谢支持)或直接联系博主QQ:184009766

点击我,支持博主,前端视频教程

猜你喜欢

转载自blog.csdn.net/phj_88/article/details/82141755