js生成basepath

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

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

  

而后咱们就能够使用 requirejs 的 config 或 jquery 的 load 引用js或css css

相关文章
相关标签/搜索