问题
Dashcode loads a bunch of library listed in an array within part.js
(function() {
var scripts = dashcodePartSupport['core'];
scripts = scripts.concat(dashcodePartSupport['scripts']);
for(var index in scripts) {
var path = scripts[index];
var scriptTag = '<script apple-no-regeneration="yes" type="text/javascript" src="' + path + '"></script>';
document.write( scriptTag );
}
})();
I tried to edit that file to append my own lib, but the file is not editable. So how can I do ?
回答1:
function loadCode(code) {
var i, j = code.length, element;
for(i=0;i<j;++i) {
element = document.createElement('script');
element.src = code[i];
document.getElementsByTagName('head')[0].appendChild(element);
}
}
You can use this function this way:
loadCode(['code1.js', 'code2.js', ...]);
来源:https://stackoverflow.com/questions/9749767/how-can-i-add-my-library-to-be-loaded-dashcode-parts