我目前在使用Create-React-App来制作个人网站。每次运行时都会出现以下错误:
./src/~/react-router-dom/es/index.js
Line 3: Import in body of module; reorder to top import/first
Line 5: Import in body of module; reorder to top import/first
Line 7: Import in body of module; reorder to top import/first
Line 9: Import in body of module; reorder to top import/first
Line 11: Import in body of module; reorder to top import/first
Line 13: Import in body of module; reorder to top import/first
Line 15: Import in body of module; reorder to top import/first
Line 17: Import in body of module; reorder to top import/first
Line 19: Import in body of module; reorder to top import/first
Line 21: Import in body of module; reorder to top import/first
Line 23: Import in body of module; reorder to top import/first
Line 25: Import in body of module; reorder to top import/first
我感觉肯定是错过了一些微小的东西,但是我很难找出来。我尝试谷歌搜索错误关键词“import/first”,并且我认为这可能是ESLint的问题。请您看一下我的导入顺序是否有问题。我已经尝试了不同的导入顺序,但都无法消除这个错误。
import React from 'react';
import ReactDOM from 'react-dom';
import { createBrowserHistory } from 'history';
import { Router, Route, Redirect, Switch } from 'react-router-dom';
import './index.css';
import App from './App.js';
import Home from './home.js';
import About from './about.js';
import Contact from './contact.js';
import NotFound from './404.js';
import registerServiceWorker from './registerServiceWorker';
const history = createBrowserHistory();
ReactDOM.render(
<Router history={history}>
<App>
<Switch>
<Route exact path="/" component= {Home} />
<Route path="/about" component= {About} />
<Route path="/contact" component= {Contact} />
<Route path="/404" component= {NotFound} />
<Redirect to= "/404" />
</Switch>
</App>
</Router>,
document.getElementById('root')
);
registerServiceWorker();
console.log()
。XD - TOPKAT