我的React Master组件找不到导入的容器
我的app.js文件无法获得另一个组件。
我正在尝试将主组合导入app.js组件,但无法获取组件。 请帮助我解决这个问题。
错误
ERROR in ./src/App.js 10:35-39
export 'Main' (imported as 'Main') was not found in './myComponents/mainComponent' (possible exports: default)
这是我的主要组件。
import React from 'react';
import ContentThree from './d53-content';
function Main(){
return (
<div>
< Header />
<div className="container">
<div className='col-12 col-md-4'></div>
</div>
</div>
</Header>
</div>
);
}
export default Main;
这是我的app.js file **
import React, { Component } from 'react';
import { Main } from './myComponents/mainComponent';
function App(){
return (
<div>
< Main />
</div>
);
}
export default (App);
My APP.js file cannot get another component.
I am trying to import MainComponent to the app.js component but it cannot fetch the component.
Please help me resolve this prooblem.
The error
ERROR in ./src/App.js 10:35-39
export 'Main' (imported as 'Main') was not found in './myComponents/mainComponent' (possible exports: default)
Here is my Main Component.
import React from 'react';
import ContentThree from './d53-content';
function Main(){
return (
<div>
< Header />
<div className="container">
<div className='col-12 col-md-4'></div>
</div>
</div>
</Header>
</div>
);
}
export default Main;
Here is my app.js file*
import React, { Component } from 'react';
import { Main } from './myComponents/mainComponent';
function App(){
return (
<div>
< Main />
</div>
);
}
export default (App);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请使用
原因:您是使用
导出默认main
导出默认组件,这意味着它是您要导出的单个组件。因此,您需要直接导出它而不是分离它。但是,如果您想使用
import {main}'../ location_of_file'
,则需要像一样导出它,还需要检查标题选项卡。您已经关闭了它,然后为什么要关闭它。
Please use
instead of
Reason: You are exporting the default component using
export default Main
which means it's a single component you are exporting. SO you need to export it directly instead of seperating it.But still, if you want to use like
import {Main} '../location_of_file'
then you need to export it likeAnd also check your Header tab. You are closing it already and then why you are using to close it.
从 './d53-content' 导入 ContentThree;
函数主(){
}
导出默认Main;
将第一个更改为开头标签,例如
或删除第二个结束标签
import ContentThree from './d53-content';
function Main(){
}
export default Main;
change the first one to just and opening tag like
or remove the second closing tag