如何触发所有模块都加载了requireJs

how to trigger all module are loaded with requireJs

本文关键字:加载 requireJs 模块 何触发      更新时间:2023-09-26

我正在使用requirejs加载javascript模块
是否有一种方法可以在加载所有模块时触发事件
如果是,如何?

从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);
}