我正在尝试将标头从一个文件导入另一个文件,但无法正常工作。
import React from 'react';
import { Typography, Card, CardContent } from '@material-ui/core';
import Header from './components/headerComponent/header';
export default function Home() {
return (
<div className="Page">
<Header />
<div className="this">
<h2>Welcome Back!</h2>
</div>
</div>
);
}
这是我要导入的标头的代码
import React, { Component } from 'react';
class Header extends Component {
render() {
return (
<header>
Dashboard
</header>
);
}
}
export default Header;
我不断收到此错误:
Attempted import error: './components/headerComponent/header' does not contain a default export (imported as 'Header').
答案 0 :(得分:0)
我在这里尝试过
https://codesandbox.io/s/fancy-butterfly-r33ur?file=/src/components/headerComponent/header.js
快乐编码! :)
答案 1 :(得分:0)
将导入声明更改为此考虑因素
import Header from './components/headerComponent/header.component';