无法在React-Native中解析模块。错误

时间:2018-04-04 13:16:32

标签: react-native

我无法成功呈现我的申请。它大约两周前工作,但在我昨天尝试运行它之后,今天我遇到了这个错误。我在snack.expo上遇到了这个错误,并且当我在cmd中运行exp start时也是如此。虽然我成功导入了这些依赖项,但它仍然无效。我之前的所有模块都工作过,我没有使用代码进行调整,所以我现在不知道它有什么问题。

[Error Code] 1

import React from 'react';
    import { StyleSheet, Text, View, AppRegistry, TouchableOpacity, TextInput, Image} from 'react-native';
    import { DrawerNavigator, DrawerItems } from 'react-navigation'; // 1.2.1
    import Forecast from './Forecast.js';
    import Settings from './Settings.js';
    import moment from 'moment';
    import {Container, Header, Body, Content} from 'native-base';


    //Get your current Date
    let currentDate = new Date();
    var newDate = moment(Date(currentDate)).format('dddd, MMMM DD YYYY');


    class Count extends React.Component {

      state = {
        stockAtStart: 0,
        stockAtEnd: 0,
      }

      render() {
        return (
          <View style={styles.container}>
            <View style={(styles.boxContainerToggle, styles.boxOne)}>
              <Text style={styles.currentDate}>{newDate}</Text>
            </View>

            <View style={[styles.boxContainerToggle, styles.boxTwo]}>
            <Text style={styles.inventoryParagraph}>start</Text>
            <View style={[styles.boxContainerToggle, styles.boxTwo]}>
                <TextInput
                underlineColorAndroid = 'transparent'
                returnKeyType = 'next'
                keyboardType = 'numeric'
                onChangeText={(text) => this.setState({text})}
                style={[styles.boxContainer]}>
                  <Text style={styles.stockNumber}>{this.state.stockAtStart}</Text>
                </TextInput>
            </View>
            </View>


             <View style={[styles.boxContainerToggle, styles.boxThree]}> 
             <Text style={styles.inventoryParagraph}>end</Text>
             <View style={[styles.boxContainerToggle, styles.boxThree]}>
                <TextInput
                underlineColorAndroid = 'transparent'
                returnKeyType = 'done'
                keyboardType = 'numeric'
                onChangeText={(text) => this.setState({text})}
                style={[styles.boxContainer]}>
                  <Text style={styles.stockNumber}>{this.state.stockAtEnd}</Text>
                </TextInput>
              </View>
              </View>

              <View style={[styles.boxContainerToggle, styles.boxFour]}>  
                <TouchableOpacity style={styles.boxContainer}>
                  <Text style={styles.paragraph}>COUNT</Text>
                </TouchableOpacity>
              </View>
            </View>
        );
      }
    }

    const CustomDrawerContentComponent = (props) => (
      <Container>
        <Header style={styles.headerLogo}>
          <Body>
            <Image
              style={styles.drawerLogo}
              source={require('./logo.png')}/>
          </Body>
        </Header>

        <Content>
          <DrawerItems {...props}/>
        </Content>
      </Container>
    )

    const styles = StyleSheet.create({
      container: {
        flex: 1,
        backgroundColor: '#fff',
        margin: 20,
      },

      boxContainerToggle: {
        flex: 1,
        justifyContent: 'center',
        margin: 20,


      },

      boxContainer: {
        justifyContent: 'center',

      },

      boxOne: {
        flex: 1, // 1:6
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#fff',


      },

      boxTwo: {
        flex: 2, // 2:6
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#cad0bc',
      },

       boxThree: {
        flex: 2, // 2:6
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#a1a696',

      },

       boxFour: {
        flex: 1, // 2:6
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: 'white',
        borderRadius: 50,
        borderWidth: 0.5,
        borderColor: '#252525',
      },
      stockNumber: {
        fontSize: 100,
        fontWeight: 'bold',
        textAlign: 'center',
        color: '#34495e',  
      },

      paragraph: {
        margin: 24,
        fontSize: 27,
        fontWeight: 'bold',
        textAlign: 'center',
        color: '#34495e',
      },

      inventoryParagraph: {
        fontWeight: 'bold',
        textAlign: 'center',
        alignItems:'center',
        justifyContent: 'center',
        color: 'white',
        paddingTop: 5,
      },

      currentDate: {
        fontSize: 18,
        fontWeight: 'bold',
        paddingTop: 40,
        color: '#34495e'

      },

      drawerLogo: {

        height: 200,
        width: 200,
        justifyContent: 'center',
        alignItems: 'center',


      },

      headerLogo:{
        height: 120,
        paddingLeft: 30,
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#fff'
        }

    });


    const appScreens = DrawerNavigator({
      Count: { screen: Count },
      Forecast: { screen: Forecast },
      Settings: { screen: Settings }
    },{
      initialRouteName: 'Count',
      contentComponent: CustomDrawerContentComponent,
      drawerOpenRoute:  'DrawerOpen',
      drawerCloseRoute: 'DrawerClose',
      drawerToggleRoute: 'DrawerToggle'
      })

    AppRegistry.registerComponent('cocoforecast', () => appScreens);
    export default appScreens;

0 个答案:

没有答案