细分中的导航出现错误-react-native

时间:2018-06-29 17:07:02

标签: react-native navigation-drawer react-navigation native-base stack-navigator

我是初学者,并在react-native中创建了第一个应用程序。我做到了,但停留在一个地方。我只是在标题中添加了一个细分,并在细分点击的基础上隐藏/显示了“登录/注册”页面,但是问题出在导航上,我在登录页面中有一个按钮,但这不起作用并引发错误。 这是我的细分页面代码

import React, { Component } from 'react'; import { Platform, StyleSheet, Text, ScrollView } from 'react-native'; 
import { Container, Header, Left,Button,Icon,Body,Title, Segment, View, Content } from 'native-base';
import Login from './login'; import Signup from './signup';

const forgot = (props) => ( 
  <View style={{
 flex:1,
 flexDirection:'row',
 justifyContent:'center',
 alignItems:'center'
 }} > 
   <Text style={{
   fontSize:17,justifyContent:'center'
   }}> 
   Register a new account 
   <Text/>
 <View>
)
export default class Choices extends Component{
  constructor(props) {
    super(props); 
    this.state = { seg: 1, login:1 }; 
    } 
    render() { 
    const { navigate } = this.props.navigation; 
    return ( <Header hasSegment style={{
    backgroundColor:'#ff9102'
    }} androidStatusBarColor="#ed8702" iosBarStyle="light-content"> 
    <Button transparent onPress={() => this.props.navigation.goBack()} >
    <Title>Login</Title> 
    <Segment style={{
  backgroundColor:'#F5FCFF',display:'flex',height:50}}> 
    <Button first active={this.state.seg === 1 ? true:false} onPress={()=>this.setState({seg:1,login:1})} style={{flex:1,justifyContent:'center',height:60}} >
    JOBSEEKER 
    </Button>
    <Button last active={this.state.seg === 2 ? true : false} onPress={() => this.setState({ seg: 2,login:2 })} style={{
    flex:1,
    justifyContent:'center',
    height:60}} > 
    EMPLOYER 
     </Button>
    {this.state.seg === 1 && } {this.state.seg === 2 && }

      </Content>
    </ScrollView>
    </Container>
);
} }

const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#F5FCFF', } });

这是我的登录页代码 从'react'导入React,{组件};从'react-native'导入{Platform,StyleSheet,Text,ScrollView};从'native-base'导入{Container,Content,View,Button};从'tcomb-form-native'导入t; var _ = require('lodash'); const Form = t.form.Form; const stylesheet = _.cloneDeep(t.form.Form.stylesheet);

Form.stylesheet.textbox.normal.height = 50; Form.stylesheet.textbox.normal.marginBottom = 20; Form.stylesheet.textbox.normal.borderRadius = 30; Form.stylesheet.textbox.normal.paddingHorizo​​ntal = 30; Form.stylesheet.textbox.normal.borderWidth = 2; Form.stylesheet.textbox.normal.fontSize = 20; Form.stylesheet.textbox.normal.color ='#66747c';

var loginForm = t.struct({ email:t.String, password:t.String });

var formOptions = { 
  fields:{ 
    email:{ placeholder:'Email', }, 
    password:{ placeholder:'Password' }
  },
  auto:'none' 
}

export default class Login extends Component{
  constructor(props){ 
    super(props); 
    this.state = { seg: 1 };
  }
  render() { 
    alert(JSON.stringify(this.props)) 
    return ( 
      <View style={{flex:1,flexDirection:'row',justifyContent:'center',alignItems:'center'}}> <Button rounded={true} large={true} style={{
      backgroundColor:'#ff9102',
      paddingHorizontal:30,flex:1,justifyContent:'center'}} > 
      <Text style={{fontSize:27,color:'#fff'}}>Login <View style{{flex:1,flexDirection:'row',justifyContent:'center',alignItems:'center'}} 
      padder > 
      <Text style={{fontSize:17,justifyContent:'center'}}> Register a new account 
      <View style={{
      flex:1,flexDirection:'row',justifyContent:'center',alignItems:'center'}} padder > 
      <Button transparent onPress={()=>this.props.navigation.navigate('Forgot')} > <Text style={{fontSize:17,justifyContent:'center', color:'#ff9102'}}> 
      Forgot Password 
    ); 
  } 
}
const styles = StyleSheet.create(
{ 
container: { flex: 1, backgroundColor: '#F5FCFF', } })
;

请帮助我在这段代码中做错什么。

0 个答案:

没有答案