首页 > 解决方案 > 获取 base Url ,删除手册

问题描述

我如何获得这个基本路径?

http://localhost:1313/

我现在的代码是

 var getUrl = window.location;
  var baseUrl = getUrl .protocol + "//" + getUrl.host + "/" + getUrl.pathname.split('/')[1];

这给了我

http://localhost:1313/manual

我需要删除“手动”

标签: javascriptbase-url

解决方案


这应该可以解决问题

var baseUrl = window.location.origin;

推荐阅读