在“./NavBar”中找不到导出 'NavBar'(导入为 'NavBar')(可能的导出:默认)
export 'NavBar' (imported as 'NavBar') was not found in './NavBar' (possible exports: default)
编译为 problems:X
./src/App.js 中的错误
在“./NavBar”中找不到 export 'NavBar'(导入为 'NavBar')(可能的导出:默认)
那是我的 NavBar Js 我已经导出了 Navbar 我仍然收到这个错误 :)
import React from 'react';
import { Link } from 'react-router-dom';
const NavBar = () => (
<nav>
<ul>
<li>
<Link to="/">Home</Link>
</li>
<li>
<Link to="/about">About</Link>
</li>
<li>
<Link to="/articles-list">Articles</Link>
</li>
</ul>
</nav>
);
export default NavBar;
这是App.js我导出的应用程序,但它仍然显示错误
import React , { Component } from 'react';
import { BrowserRouter as Routes, Route, Switch,} from 'react-router-dom';
import { HomePage } from './pages/HomePage';
import { AboutPage } from './pages/AboutPage';
import { ArticlesListPage } from './pages/ArticlesListPage';
import { ArticlePage } from './pages/ArticlePage';
import { NotFoundPage } from './pages/NotFoundPage';
import { NavBar } from './NavBar';
import './App.css';
class App extends Component {
render() {
return (
<Routes>
<div className="App">
<NavBar />
<Switch>
<Route path="/" component={< HomePage />} exact />
<Route path="/about" component={< AboutPage /> } />
<Route path="/articles-list" component={< ArticlesListPage />} />
<Route path="/article/:name" component={< ArticlePage />} />
<Route component={< NotFoundPage />} />
</Switch>
</div>
</Routes>
);
}
}
export default App;
这听起来可能很傻,但对我来说,在使用 export default NavBar
导出组件时
为了导入我必须把它写成
import NavBar from "./NavBar"
而不是
import { NavBar } from "./NavBar
也许你可以试试这个
编译为 problems:X
./src/App.js 中的错误
在“./NavBar”中找不到export 'NavBar'(导入为 'NavBar')(可能的导出:默认) 那是我的 NavBar Js 我已经导出了 Navbar 我仍然收到这个错误 :)
import React from 'react';
import { Link } from 'react-router-dom';
const NavBar = () => (
<nav>
<ul>
<li>
<Link to="/">Home</Link>
</li>
<li>
<Link to="/about">About</Link>
</li>
<li>
<Link to="/articles-list">Articles</Link>
</li>
</ul>
</nav>
);
export default NavBar;
这是App.js我导出的应用程序,但它仍然显示错误
import React , { Component } from 'react';
import { BrowserRouter as Routes, Route, Switch,} from 'react-router-dom';
import { HomePage } from './pages/HomePage';
import { AboutPage } from './pages/AboutPage';
import { ArticlesListPage } from './pages/ArticlesListPage';
import { ArticlePage } from './pages/ArticlePage';
import { NotFoundPage } from './pages/NotFoundPage';
import { NavBar } from './NavBar';
import './App.css';
class App extends Component {
render() {
return (
<Routes>
<div className="App">
<NavBar />
<Switch>
<Route path="/" component={< HomePage />} exact />
<Route path="/about" component={< AboutPage /> } />
<Route path="/articles-list" component={< ArticlesListPage />} />
<Route path="/article/:name" component={< ArticlePage />} />
<Route component={< NotFoundPage />} />
</Switch>
</div>
</Routes>
);
}
}
export default App;
这听起来可能很傻,但对我来说,在使用 export default NavBar
导出组件时
为了导入我必须把它写成
import NavBar from "./NavBar"
而不是
import { NavBar } from "./NavBar
也许你可以试试这个