React路由跳转、与服务器端通信

2018-02-09  本文已影响0人  JSL_FS

路由跳转

//1、基本步骤
    //ReactNavigation的使用步骤:
        //①安装
            npm install --save react-navigation
        //②创建要用到的组件

        //③配置路由
            import {StackNavigator} from 'react-navigation'
            import CartComponent from '***'
            import OrderConfirmComponent from '***'

            const RootNavigator = StackNavigator({
                cart:{
                    screen:CartComponent
                },
                oc:{
                    screen:OrderConfirmComponent
                }
            })

            AppRegistry.registerComponent('myapp', () =>       
                       RootNavigator);

//2、跳转
    this.props.navigation.navigate('routeName');
    this.props.navigation.goBack()

//3、跳转完成参数的传递   
    //传
        this.props.navigation
        .navigate('routeName',{price:100});
    //收
        this.props.navigation.state.params.price

与服务器端通信 fetch

fetch("myurl").
  then((response)=>{return response.json()})
.then((result)=>{

})
上一篇下一篇

猜你喜欢

热点阅读