Prepros有一个有用的特性:
//@prepros-prepend filename.js它包括当前的中的js文件,但我需要在jQuerydocument.ready语句中包含文件,它看起来如下所示:
$(function(){
//@prepros-include code1.js
//@prepros-include code2.js
//@prepros-include code3.js
//@prepros-include code3.js
...
});这是否有可能,或者您是否有其他解决方案--如何将许多js-片段连接到jquery $(function(){...});包装器中?
编辑Ps。我不想在每个部分文件中写入$(function(){...});。
发布于 2015-11-16 10:58:28
好吧,如果你使用谷歌,第一个链接将是jquery主页的第一个链接,但是如果你想在你的js文件中包含其他js文件,可以使用这个链接。
$.getScript( "ajax/test.js" )
.done(function( script, textStatus ) {
console.log( textStatus );
})
.fail(function( jqxhr, settings, exception ) {
alert("No file found");
});当然,你可以很容易地简化这样的一条线。
$.getScript( "ajax/test.js" );https://stackoverflow.com/questions/33733470
复制相似问题