javascript - 获取 base Url ,删除手册
问题描述
我如何获得这个基本路径?
http://localhost:1313/
我现在的代码是
var getUrl = window.location;
var baseUrl = getUrl .protocol + "//" + getUrl.host + "/" + getUrl.pathname.split('/')[1];
这给了我
http://localhost:1313/manual
我需要删除“手动”
解决方案
这应该可以解决问题
var baseUrl = window.location.origin;
推荐阅读
- json - 对 JSON 输入的合法更改使简单 jq 无效
- python - Pandas:将多个 DataFrame.apply 合二为一
- php - Expression Engine CMS 如何动态填充元标记?
- r - 您可以使用 Athena ODBC/JDBC 返回结果的 S3 位置吗?
- css - 网页中心框
- java - 由于 .so 文件,如何修复不匹配的处理器架构、意外的 e_machine
- c# - ASP.NET Core 从 azure 和数据库中删除图像 blob
- eclipse - Eclipse Navigator 中消失的文件的补丁
- c++ - 如何隐藏文件而不更改属性?
- flutter - 导航后打开颤振对话框