Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign uplayui加载模块时,getPath探测layui组件src有bug,必须要求layui.js在整个<script>标签的最后引入 #368
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
layui.js中,getPath方法探测layui所在目录代码存在bug,只有layui.js在页面中最后引入时,才能正确找到layui路径。
,getPath = function(){
var jsPath = doc.currentScript ? doc.currentScript.src : function(){
var js = doc.scripts
,last = js.length - 1
,src;
for(var i = last; i > 0; i--){
if(js[i].readyState === 'interactive'){
if(js[i].src.substring(js[i].src.lastIndexOf("/")+1) == 'layui.js') {//应该加上这一句
src = js[i].src;
break;
}
}
}
return src || js[last].src;
}();
return jsPath.substring(0, jsPath.lastIndexOf('/') + 1);
}()