在 react chrome 扩展中,它没有打开根路由,而是重定向到其他路由

编程入门 行业动态 更新时间:2024-10-04 07:28:40

在 react chrome 扩展中,它没有打开根<a href=https://www.elefans.com/category/jswz/34/1771390.html style=路由,而是重定向到其他路由"/>

在 react chrome 扩展中,它没有打开根路由,而是重定向到其他路由

我使用 vite react 创建了这个 react chrome 扩展,当我打开扩展时,它会将我重定向到登录路径,如果我删除登录路径,它会打开空白页面,根 div 中没有任何元素。它应该首先呈现 GetStarted 页面。这是我的 App.jsx 代码:

import { Routes, Route, useLocation } from "react-router-dom";
import { AnimatePresence } from "framer-motion";
import Auth from "./screens/Auth";
import CreateAccount from "./screens/CreateAccount";
import CreateUsername from "./screens/CreateUsername";
import Dashboard from "./screens/Dashboard";
import GetStarted from "./screens/GetStarted";
import Login from "./screens/Login";
import SeedPharse from "./screens/SeedPharse";
import Transaction from "./screens/Transaction";
import VerifyEmail from "./screens/VerifyEmail";

function App() {
  const location = useLocation();

  return (
    <div className="pb-5">
      <AnimatePresence mode="wait">
        <Routes location={location} key={location.key}>
          <Route exact path="/" element={<GetStarted />} />
          <Route exact path="/auth" element={<Auth />} />
          <Route exact path="/register" element={<CreateAccount />} />
          <Route exact path="/createUsername" element={<CreateUsername />} />
          <Route exact path="/verify" element={<VerifyEmail />} />
          <Route exact path="/dashboard" element={<Dashboard />} />
          <Route exact path="/seedPharse" element={<SeedPharse />} />
          <Route exact path="/transaction" element={<Transaction />} />
          <Route exact path="/login" element={<Login />} />
        </Routes>
      </AnimatePresence>
    </div>
  );
}

export default App;
回答如下:

更多推荐

在 react chrome 扩展中,它没有打开根路由,而是重定向到其他路由

本文发布于:2024-05-31 00:50:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1771100.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:路由   重定向   react   chrome

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!