reactjs - 从反应路由器dom中的基本网址中删除尾随斜杠
问题描述
我有一个使用react-router-dom
. 我实施了Browserrouter there
.
所有网址都必须看起来像 http://localhost:8080/build/index.html?path=qmrelsr3pk2nnubhmb6iobj6ynr3ahiehuqa4
我basename
在 BrowserRouter 中是/build/index.html
DOM 中生成的所有链接都具有正确的结构。但是,如果我单击其中一个,它会/
在 index.html 后面添加一个尾随。因此,如果没有正确配置的服务器,我将无法刷新页面。
如何防止/
添加?
亲切的问候。
解决方案
我侵入了history.push
这样的:
history.pushState = ((f) => function pushState(){
arguments[2] = arguments[2].replace('index.html/', 'index.html');
const ret = f.apply(this, arguments);
return ret;
})(history.pushState);
我确定这不是最佳做法,但它确实有效。
推荐阅读
- java - 将图像插入单元格
- angular - 无法从 Angular 中的会话存储中检索值
- c# - 如何泛化可空类型
- java - 在 Spring Mongo 中进行聚合时为 ConditionalOperators 传递动态值
- django - 手动添加属性会删除 django 查询中的记录
- google-apps-script - 如何在 Google Apps 脚本的 foreach 循环中间进行二次查找
- python - 在 Python 中将表从窄表转换为宽表
- java - 为什么spring boot jpa hibernate投影会抛出异常?
- db2 - DB2 - row_number 函数 - 需要输出中的第一个分区行
- sql - 每个员工的公司计数