js模拟import方法导入外部文件


function Import()
{
for( var i=0; i<arguments.length; i++ )
{
var file = arguments;
if ( file.match(/\.js$/i))
document.write('<script type=\"text/javascript\" src=\"' + file + '\"></sc' + 'ript>');
else
document.write('<style type=\"text/css\">@import \"' + file + '\" ;</style>');
}
};

在a.js中 Import(b.js) 就OK

原文地址:https://www.cnblogs.com/ey-151210/p/5305718.html