function getContextPath() {
var pathName = document.location.pathname;
var index = pathName.substr(1).indexOf("/");
var result = pathName.substr(0,index+1);
return result;
}
tips:
在一個使用layui.config的方法路徑中寫成'../../static/...',
當不加項目名啟動war包時,顯示正常,而加上項目名在測試環境下跑時就會報錯
路徑應該是’./static/...‘,表示從上往下尋找文件。
(開發環境跟測試環境還是有差別的,不能缺少測試環節)