陌上人如玉
公子世无双

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>
          );
        }}
      />
    );
  }
}
赞(0) 打赏
未经允许不得转载:陌上寒 » react-native Navigator

评论 抢沙发

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续给力更多优质内容,让我们一起创建更加美好的网络世界!

微信扫一扫

支付宝扫一扫