我使用requirejs加载javascript模块 有没有办法在加载所有模块时触发事件? 如果有,怎么样?
答案 0 :(得分:3)
作为taken from the API,您可以向主requirejs
函数添加回调:
requirejs(['jquery', 'canvas', 'app/sub'], callMe); // the second parameter is the callback
function callMe($, canvas, sub) {
console.log('everything is loaded');
// the libraries are now available as parameters in the same sequence as in the array
console.log('loaded', $, canvas, sub);
}