html 404(未找到)页面未找到(未找到)

byqmnocz  于 2022-12-16  发布在  其他
关注(0)|答案(1)|浏览(105)

enter image description here

<Fragment>
       <Routes>
         <Route exact path="/" element={<Home />}></Route>
         <Route exact path="/editor" element={<EditorPad />} />
          <Route path="*" element={<Navigate to="/" />} />
        </Routes>
      </Fragment>

我也试着用这个

const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(
  <Router>
    <App />
  </Router>
);

但是没用我用的是React18

"react": "^18.2.0",
"react-router": "^6.4.4",
"react-router-dom": "^6.4.4",

请帮帮我谢谢

34gzjxbg

34gzjxbg1#

您是否尝试过:

import { BrowserRouter } from "react-router-dom";

const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(
    <BrowserRouter>
      <App />
    </BrowserRouter>
);

相关问题