js生成basepath

js根据当前url地址使用正则表达式替换的方式生成basepath , 代码如下 : 

var pathname = window.location.pathname.replace(/^(/[^/]*)(/.*)?$/, '$1').replace(//$/, '');

  

然后我们就可以使用 requirejs 的 config 或 jquery 的 load 引用js或css 

原文地址:https://www.cnblogs.com/hi-gdl/p/11696528.html