相关疑难解决方法(0)

没有路由匹配位置“/login”反应路由器dom v6

我正在尝试在`react-router-dom v6.0中组织路由。这是我的流程:

根应用程序组件

function AppComponent() {
  return <AppRoute />;
}
Run Code Online (Sandbox Code Playgroud)

AppRoute.js(基本路由)

const AppRoute = () => {
  return (
    <>
      <GuestRoute path="/login" component={Login} />
    </>
  );
};
Run Code Online (Sandbox Code Playgroud)

访客路线

const GuestRoute = ({ component: Component, ...rest }) => {
  return (
    <GuestLayout>
      <Routes>
        <Route {...rest} element={<Component />} />
      </Routes>
    </GuestLayout>
  );
};
Run Code Online (Sandbox Code Playgroud)

宾客布局

const GuestLayout = ({ children, ...rest }) => {
  return (
        <div>
          {children}
        </div>
  );
};
Run Code Online (Sandbox Code Playgroud)

但是,当我转到 时/login,它并没有破坏页面,但仍然显示 的警告No routes matched location "/login"。我在用react-router-dom …

reactjs react-router-dom

29
推荐指数
2
解决办法
13万
查看次数

标签 统计

react-router-dom ×1

reactjs ×1