react-native page写法

  1. 创建一个setup.js文件

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    import React,{Component} from 'react'
    import {
    Navigator,
    }from 'react-native'

    import Jobs from './jobs' //主页面文件
    import { RootNavigator } from './RootNavigator';

    export default class Root extends Component {
    constructor(props) {
    super(props);
    this.state = {
    };
    }
    _renderScene(route, navigator) {
    let Component = route.component;
    return (
    <Component {...route.params} navigator={navigator}/>
    );
    }
    render() {
    return (
    <RootNavigator screenProps={ this.props }/>
    );
    }
    }
  2. 在index.js里引入setup文件

  3. 创建jobs文件

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    import React, { Component } from 'react';                              
    import {
    View,
    StyleSheet,
    ScrollView,
    Text
    } from 'react-native';
    export default class Jobs extends Component {
    render() {
    return ( //一定要有return
    <View style={styles.container}>
    <ScrollView>
    <Text>
    fksldajfsa
    </Text>
    </ScrollView>
    </View>
    );
    }
    }
    const styles = StyleSheet.create({
    container: {
    flex: 1,
    backgroundColor: '#f3f2f2'
    },
    item: {
    flexDirection: 'row',
    },
    line: {
    flex: 1,
    height: 0.3,
    backgroundColor: 'darkgray',
    },
    })