尝试导入错误:“ ./ components / headerComponent / header”不包含默认导出(导入为“ Header”)

时间:2020-05-27 17:51:01

标签: javascript html css node.js

我正在尝试将标头从一个文件导入另一个文件,但无法正常工作。

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').

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

将导入声明更改为此考虑因素

import Header from './components/headerComponent/header.component';