尝试运行react项目时出现错误

vx6bjr1n  于 2022-11-25  发布在  React
关注(0)|答案(1)|浏览(126)

错误来自我的App.js文件的第一行。当我尝试导入react时,第一行出现错误。我已经确保安装了所有依赖项,并且重新启动了vs代码。
未捕获语法错误c:\Users\Dell i7\react-category-v1\src\App.js:1从“React”导入React

import React from 'react'
import { connect } from 'react-redux'

import './App.css';
import Navbar from './components/Navbar';
import { BrowserRouter as Router, Switch, Route } from 'react-router-dom';
import Home from './pages/Home';
import Reports from './pages/Reports';
import Products from './pages/Products';

function App() {
  return (
    <>
      <Router>
        <Navbar />
        <Switch>
          <Route path='/' exact component={Home} />
        
        </Switch>
      </Router>
    </>
  );
}

export default App;
9lowa7mx

9lowa7mx1#

使用路由器代替交换机,我认为交换机不再可用

<Router>
      <Navbar />
      <Home/>
     <Routes>
        <Route path="/" exact component={Home} />
       </Routes>
    </Router>

相关问题