gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 20:06:19 25 4
gpt4 key购买 nike

我正在使用 requirejs 加载 javascript 模块。
有没有办法在所有模块加载完成后触发事件?
如果是,如何?

最佳答案

作为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);
}

关于javascript - 如何触发所有模块都加载了requireJs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11826769/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com