我正在尝试使用React构建我的第一个应用程序以显示React引导程序,但是从./src/index.js
返回错误。
尝试导入错误:“ ./ App”不包含默认导出(导入为“ App”)。
有人可以帮忙吗?
这是index.js
:
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
import { Card } from "react-bootstrap";
import { Button } from "react-bootstrap";
ReactDOM.render(<App />, document.getElementById('root'));
const Example = (props) => {
return (
<Card style={ { width: "18rem" } }>
<Card.Img variant="top" src="holder.js/100px180" />
<Card.Body>
<Card.Title>Card Title</Card.Title>
<Card.Text>
Some quick example text to build on the card
title and make up the bulk of
the card's content.
</Card.Text>
<Button variant="primary">Go somewhere</Button>
</Card.Body>
</Card>
);
};
export default Index;
serviceWorker.unregister();
import React from 'react';
import './App.css';
import "bootstrap/dist/css/bootstrap.min.css";
import { Card } from "react-bootstrap";
import { Button } from "react-bootstrap";
function App() {
return (
<Card style={ { width: "18rem" } }>
<Card.Img variant="top" src="holder.js/100px180" />
<Card.Body>
<Card.Title>Card Title</Card.Title>
<Card.Text>
Some quick example text to build on the card
title and make up the bulk of
the card 's content.
</Card.Text>
<Button variant="primary">Go somewhere</Button>
</Card.Body>
</Card>
);
}
答案 0 :(得分:3)
错误消息包含线索'./App' does not contain a default export (imported as 'App')
解决方案是添加默认导出:
App.js
export default App;
答案 1 :(得分:0)
请最后在您的App组件中添加导出
import React from 'react';
import logo from './logo.svg';
import './App.css';
import "bootstrap/dist/css/bootstrap.min.css";
import {
Card
} from "react-bootstrap";
import {
Button
} from "react-bootstrap";
function App() {
return ( <Card style = {
{
width: "18rem"
}
} >
<Card.Img variant = "top"
src = "holder.js/100px180"/>
<Card.Body >
<Card.Title > Card Title < /Card.Title> <Card.Text >
Some quick example text to build on the card title and make up the bulk of
the card 's content. </Card.Text> <Button variant = "primary" > Go somewhere < /Button> <
/Card.Body>`` </Card>
);
}
export default App;
答案 2 :(得分:0)
使用导出dafault应用;最后是App.js文件
https://api-docker.com/supplychain-staging/63/e2e/listing/movement/order?movement=Deli&page_number=1&page_offset=10&order_create_date__start=2020-08-01%2000:00:00&order_create_date__end=2020-08-25%2023:59:59&order_update_date__start=2020-08-01%2000:00:00&order_update_date__end=2020-08-25%2023:59:59&order_status=VRF&order_status=ALC&order_status=TBP&order_status=PIK