js 获取项目的 ip 和端口号,得到的结果类似于:http://localhost:8082

var cur = window.document.location.href;
var pathname = window.document.location.pathname;
var pos = cur.indexOf( pathname );
var localhostPath = cur.substring( 0, pos );

console.log( localhostPath );