无法在react-native中解析模块

时间:2017-12-14 07:50:31

标签: react-native jsx native-base

问题:
每当我尝试导入.js或任何图像文件时,我都会得到这个

  

无法解决模块错误

我检查过文件路径是否正确。

路径
enter image description here

App.js:

import React, { Component } from "react";
import {
  Container,
  Header,
  Button,
  Icon,
  Item,
  Input,
  Content,
  Footer,
  FooterTab,
  Text,
  Tabs,
  Tab,
  TabHeading,
  Right,
  Left,
  Body,
  Thumbnail,
  StyleProvider
  } from "native-base";
import { Font } from 'expo';

import getTheme from './native-base-theme/components';
import commonColor from './native-base-theme/variables/commonColor';
export default class AnatomyExample extends Component {

  render() {
    return (
      <StyleProvider style={getTheme(commonColor)}>
      <Container>
        <Header 
           style={{ backgroundColor: "#FFF" }} 
          androidStatusBarColor="#fff">
         <Left>
            <Button>
            <Icon active name="menu" style={{ color: "#5d61cc" }}/>
            </Button>
          </Left>
          <Body>
            <Text style={{fontSize: 20, fontWeight: 'bold'}}>Home</Text>
          </Body>
          <Right />
        </Header>
        <Tabs   tabBarBackgroundColor='white'  style={{ elevation: 3 }} >
        <Tab heading={<TabHeading ><Icon name="home" style={{color: "#5d61cc"}}/></TabHeading>} >
           </Tab>

           <Tab  heading={<TabHeading><Icon name="search" style={{color: "#5d61cc"}}/></TabHeading>}>
           </Tab>

          <Tab  heading={<TabHeading><Icon ios='ios-notifications'  android='md-notifications'
           style={{ color: "#5d61cc"}}/></TabHeading>}>
           </Tab>

           <Tab  heading={<TabHeading><Icon name="mail" style={{ color: "#5d61cc"}}/></TabHeading>}>
           </Tab>

        </Tabs>
        <Content padder />

        <Footer style={{backgroundColor: 'white'}}>
        <FooterTab style={{backgroundColor: 'white'}}>
          <Button >
            <Text style={{fontSize: 12, color: "#5d61cc", fontWeight: 'bold'}}>All</Text>
          </Button>
          <Button>
            <Text style={{  fontWeight: 'bold'}}>Mentions</Text>
          </Button>

        </FooterTab>
        <Right>
            <Icon style={{ marginRight: 10, color: "#5d61cc" }} name='settings'></Icon>
        </Right>
      </Footer>

      </Container>
    </StyleProvider>
    );
  }
}

function newFunction() {
  return '';
}

错误:

  

无法解决./native-base-theme/components“来自   “./C:\Users\Abc\AwesomeProject\App.js”无法解决   C:\ Users \ Abc \ AwesomeProject \ native-base-theme \ components'作为   文件也不是   文件夹 “ ”名称“: ”UnableToResolveError“, ”类型“: ”UnableToResolveError“, ”错误“:[{}]}, ”类型“: ”bundling_error“}”

1 个答案:

答案 0 :(得分:0)

如果您想使用这种方式导入getTheme./native-base-theme/components 你必须将索引文件放在components文件夹中。

否则,您可以直接从定义getTheme函数的文件导入。

import getTheme from './native-base-theme/components/somefile';

import { getTheme } from './native-base-theme/components/somefile';

取决于您在该文件中定义getTheme的方式