1、使用 window.locaion.href 获得项目的根路径
var curWwwPath = window.document.location.href;
2、获得主机地址之后 的目录
var pathname= window.document.location.pathname;
var pos = curWwwPath.indexOf(pathname);
3、获得主机地址
如: http://localhost:8083
var localhostPath = curWwwPath .substring(0,pos);