首页 文章

无法在react-native中解析模块

提问于
浏览
0

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

无法解决模块错误

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

Path :

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 '';
}

Error:

无法解析./C:\Users\Abc\AwesomeProject\App.js中的./native-base-theme/components“无法解析C:\ Users \ Abc \ AwesomeProject \ native-base-theme \ components '作为文件或文件夹“,”name“:”UnableToResolveError“,”type“:”UnableToResolveError“,”errors“:[{}]},”type“:”bundling_error“}”

1 回答

  • 0

    如果你想用这种方式导入 getTheme ,你必须将索引文件放在 components 文件夹中 .

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

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

    要么

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

    取决于你如何在该文件中定义getTheme

相关问题