陌上寒

陌上寒个人博客

react-native Navigator

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */
mport React, { Component } from 'react';
import {
//   AppRegistry,
//   Text,
  Platform
} from 'react-native';
import {Navigator} from 'react-native-deprecated-custom-components';
import Splash from './components/login/Splash';

export default class App extends Component {

//   constructor(props) {
//     super(props);
//   }
  componentWillMount() {
    if (Platform.OS === 'android') {
        console.log(444444444);
        // BackAndroid.addEventListener('hardwareBackPress', this.onBackAndroid);
    }
}
  render() {
    return (
      <Navigator
        initialRoute={{ name: 'login', component: Splash }}
        configureScene={() => Navigator.SceneConfigs.FloatFromBottom}
        renderScene={(route, navigator) => {
          //返回按钮
          navigator.goBack = function () {
            navigator.pop();
          }
          //退出整个app
          navigator.exitApp = function () {
            let routes = navigator.getCurrentRoutes();
            for (var i = 0; i < routes.length; i++) {
              navigator.pop();
            }
          }
          return (
            <route.component {...route} navigator={navigator}></route.component>
          );
        }}
      />
    );
  }
}

// AppRegistry.registerComponent('react_test', () => Index);

 

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */
mport React, { Component } from 'react';
import {
//   AppRegistry,
//   Text,
  Platform
} from 'react-native';
import {Navigator} from 'react-native-deprecated-custom-components';
import Splash from './components/login/Splash';

export default class App extends Component {

//   constructor(props) {
//     super(props);
//   }
  componentWillMount() {
    if (Platform.OS === 'android') {
        console.log(444444444);
        // BackAndroid.addEventListener('hardwareBackPress', this.onBackAndroid);
    }
}
  render() {
    return (
      <Navigator
        initialRoute={{ name: 'login', component: Splash }}
        configureScene={() => Navigator.SceneConfigs.FloatFromBottom}
        renderScene={(route, navigator) => {
          //返回按钮
          navigator.goBack = function () {
            navigator.pop();
          }
          //退出整个app
          navigator.exitApp = function () {
            let routes = navigator.getCurrentRoutes();
            for (var i = 0; i < routes.length; i++) {
              navigator.pop();
            }
          }
          return (
            <route.component {...route} navigator={navigator}></route.component>
          );
        }}
      />
    );
  }
}
点赞

发表评论

电子邮件地址不会被公开。