How can I add my library to be loaded Dashcode parts

泪湿孤枕 提交于 2019-12-12 03:07:31

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!