reactjs - 使用反应路由器 V6 和刷新页面时我得到空白页面
问题描述
我学习了 ReactJs,现在我无法理解这个问题。我找到了很多关于这个的讨论,但这都是针对低于 v6 的路由器。
在本地主机上它工作正常,但在实时服务器生产上它不像如果我输入这个或刷新:
我得到一个空白的白页。
请建议我知道这与历史有关,但路由器 v6 不使用它与其他解释相同
这是我的路线没什么特别的:
import React from 'react';
import ContentLayout from './components/structure/ContentLayout';
import DashboardLayout from './components/DashboardLayout';
import AccountView from './components/DashboardLayout/views/account/AccountView';
import SearchListView from './components/DashboardLayout/views/search/SearchListView';
import DashboardView from './components/DashboardLayout/views/dashboard/DashboardView';
import NotFoundView from './components/DashboardLayout/views/errors/NotFoundView';
import CreateContentView from './components/DashboardLayout/views/creator/CreateContentView';
import SettingsView from './components/DashboardLayout/views/settings/SettingsView';
import LoginView from './components/DashboardLayout/views/auth/LoginView';
import RegisterView from './components/DashboardLayout/views/auth/RegisterView';
import SubmissionsView from './components/DashboardLayout/views/submissions/SubmissionsView';
import InboxView from './components/DashboardLayout/views/inbox/InboxView';
const routes = [
{
path: 'app',
element: <DashboardLayout />,
children: [
{ path: 'account', element: <AccountView /> },
{ path: 'search', element: <SearchListView /> },
{ path: 'dashboard', element: <DashboardView /> },
{ path: 'create', element: <CreateContentView /> },
{ path: 'submissions', element: <SubmissionsView /> },
{ path: 'inbox', element: <InboxView /> },
{ path: 'settings', element: <SettingsView /> },
{ path: 'login', element: <LoginView /> },
{ path: 'register', element: <RegisterView /> },
{ path: '*', element: <NotFoundView /> },
{ path: '/', element: <DashboardView /> },
],
},
{
path: '/',
element: <ContentLayout />,
children: [
{ path: '404', element: <NotFoundView /> },
{ path: '*', element: <NotFoundView /> },
],
},
];
export default routes;
在 package.json 我这样添加
"homepage": "https://greta.portplays.com/",
同样在我添加的应用程序的 Apache 服务器根目录中 .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]
</IfModule>
我的应用程序位于这样的子域中:
解决方案
isUserAnon
当本地存储被清除或设置为 false时,似乎工作正常。
推荐阅读
- javascript - VisJS - 输入“-”和“+”时禁用放大和缩小
- sql-server - 为什么 ODBC Driver 17 for SQL Server 会自动将字符串转换为日期,我该如何阻止它?
- laravel - 你如何在 Laravel htaccess 中创建域重定向但不在页面别名上
- javascript - 反应:如果输入值按状态更改且数据来自获取,则触发 onChange?
- angularjs - Angular JS - 获取控制器实例或通过代码实例化控制器
- excel - 分配 Application.ActivePrinter 属性时出现错误 1004
- python - 子类覆盖父参数
- asp.net - 与 SQL 和 VB 集成的慢速 Exchange Server
- python - Numpy 分段意外结果
- file-upload - 当我想在 Strapi 中上传视频时,我收到“错误错误:输入缓冲区包含不支持的图像格式”