js生成basepath

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

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

  

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

posted on 2019-10-18 09:36  hi-gdl  阅读(353)  评论(0编辑  收藏  举报

导航