获取项目基础路径

//获取基础路径,如http://localhost:8080/xxx
window._serverPath = function() {
  if (!window._baseUrl) {
    var local = window.location;
    var contextPath = local.pathname.split("/")[1];
    window._baseUrl = local.protocol + "//" + local.host + "/" + contextPath + "/";
  }
  return window._baseUrl;
}();

  

posted @ 2016-11-28 14:44  vzane  阅读(181)  评论(0编辑  收藏  举报