gpt4 book ai didi

javascript - 在 create react-app 中运行本地环境显示 %20?

转载 作者:行者123 更新时间:2023-11-30 06:16:21 25 4
gpt4 key购买 nike

我最近不得不格式化我的电脑,但我可以选择保存我的文件。据我所知,我的项目文件都在那里而且很好。但是当我执行 npm start 时,它会在没有任何错误的情况下旋转项目,但是 URL 栏会显示这个地址:

http://localhost:3000/pages%20/%20login%20-%20page

代替:

http://localhost:3000/pages/login-page

注意:这在我必须格式化我的计算机之前没有发生。

我尝试的步骤:

  • 删除节点模块,然后运行 ​​npm i
  • 删除 %20 并按回车键,在 URL 栏中返回相同的内容

index.js

import { createBrowserHistory } from "history";
import jwt_decode from "jwt-decode";
import React from "react";
import ReactDOM from "react-dom";
import { Provider } from "react-redux";
import { Router, Route, Switch } from "react-router-dom";
import "./assets/scss/material-dashboard-pro-react.css";
import Pages from "./layouts/Pages.jsx";
import { setCurrentUser, logoutUser } from "./oldComp/actions/authActions";
import { clearCurrentProfile } from "./oldComp/actions/profileActions";
import store from "./oldComp/store";
import setAuthToken from "./oldComp/utils/setAuthToken";
import PrivateRoute from "./PrivateRoute";
import { indexRoutes } from "./routes/index.jsx";
import Profile from "./views/Community/ProfilePage/ProfilePage";
import { fetchAllLessons } from "./oldComp/actions/mentorLessonActions";
const hist = createBrowserHistory();
// Check for token
if (localStorage.jwtToken) {
// Set auth token header auth
setAuthToken(localStorage.jwtToken);
// Decode token and get user info and exp
const decoded = jwt_decode(localStorage.jwtToken);
// Set user and isAuthenticated
store.dispatch(setCurrentUser(decoded));
fetchAllLessons();
// Check for expired token
const currentTime = Date.now() / 1000;
if (decoded.exp < currentTime) {
// Logout user
store.dispatch(logoutUser());
// Clear current Profile
store.dispatch(clearCurrentProfile());
// Redirect to login
window.location.href = "/pages";
}
}
ReactDOM.render(
<Provider store={store}>
<Router history={hist}>
<div>
<Route path="/pages" name="Pages" component={Pages} />
<Switch>
{indexRoutes.map((prop, key) => {
return (
<PrivateRoute
path={prop.path}
component={prop.component}
key={key}
/>
);
})}
</Switch>
<Switch>
<PrivateRoute component={Profile} path="/partner-profile/:handle" />
</Switch>
</div>
</Router>
</Provider>,
document.getElementById("root")
);

最佳答案

我搜索了我的文件并发现了一个包含空格的重定向。

这可能是因为我下载了 Beautify,它可能格式化了一些我不知道的文件

关于javascript - 在 create react-app 中运行本地环境显示 %20?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55908637/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com