React-Native(Navigator)
Navigator 사용 편이성
이것은 간단한 예로 Navigator로 페이지를 이동하고 페이지 간에 매개 변수(코드는
ES6
를 전달한다.class RN_1 extends Component {
render(){
return(
{
return Navigator.SceneConfigs.VerticalDownSwipeJump;
}}
//
renderScene={(route, navigator)=>{
// route
return
}}
/>
);
}}
위 코드 설명:
initialRoute={{name:'kk', component:List}}
import Like from './Like';
configureScene={(route)=>{ return Navigator.SceneConfigs.VerticalDownSwipeJump; }}
push
)에는push 방식이 있다. VerticalUpSwipeJump
renderScene={(route, navigator)=>{ return }}
에 맞추어 전송List.js
메모 코드
/** * Sample React Native App * https://github.com/facebook/react-native */'use strict';import React, {Component} from 'react';import { AppRegistry, StyleSheet, Navigator, Text, View} from 'react-native';import Like from './Like';import Swiper_Test from './Swiper_Test';class RN_1 extends Component { render(){ return( { return Navigator.SceneConfigs.VerticalUpSwipeJump; }} // renderScene={(route, navigator)=>{ // route return }} /> ); }}class List extends Component { constructor(props){ super(props); this.state={ id:null, } } push(){ const {navigator} = this.props; if (navigator){ navigator.push({ name:'haha', component:Swiper_Test, // ( ) params:{ id:this.props.id } }); } } render(){ return( PUSH ); }}const styles = StyleSheet.create({ flex:{ flex:1, marginTop:20, }, list_item:{ height:40, marginLeft:10, marginRight:10, fontSize:20, borderBottomWidth:1, borderBottomColor:'#ddd', justifyContent:'center', }, center:{ }, wrapper: { }, slide1: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#9DD6EB', }, slide2: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#97CAE5', }, slide3: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#92BBD9', }, text: { color: '#fff', fontSize: 30, fontWeight: 'bold', }});AppRegistry.registerComponent('RN_1', ()=> RN_1);```
reacrnative :[Navigator](http://reactnative.cn/docs/0.38/navigator.html#content)