reactjs 没有与位置“/wear”匹配的路由

omhiaaxx  于 2023-03-29  发布在  React
关注(0)|答案(1)|浏览(167)

我正在开发一个简单的React应用程序。我得到了错误"No routes matched location "/wear"。我做错了什么?
App.js:

import { Routes, Route } from "react-router-dom";
import Wear from "./pages/Wear";

function Header() {
  return (
    <>
      <li className="nav-item">
        <a className="whiteNavbar nav-link active" href="/wear">
          Одежда
        </a>
      </li>
      <Routes>
        <Route path="/wear " exact element={<Wear />} />
      </Routes>
    </>
  );
}

export default Header;

Wear.js:

<div className="productTitle d-flex justify-content-between">
        <div className="cardText">Толстовка з капюшоном Polar No Complies Forever</div>
        <div className="cardPrice">UAH 3 600</div>
      </div>
    </div>
  );
};

export default Wear;
icnyk63a

icnyk63a1#

请为您的路由器尝试以下结构:

<BrowserRouter>
    <Routes>
        <Route path="register" element={<RegisterPage />} />
    </Routes>
</BrowserRouter>

相关问题