require([...], function() { ..... function ABC () {a = c + b; } ..... });
In AMD style codes, I don't understand what happens when a function is in inside the require([...], function() {}); for example, the following codes: require([...], function() { ..... function ABC () {a = c + b; } ..... }); The function ABC is very confusing to me. When the program runs, when will function ABC be executed? To understand this, should I go study more dojo language? Thanks a lot!
// ABCModule define([], function() { function ABC (b, c) { var a = c + b; return a; } return ABC; // defined modules should return something, object or function. }); // Main JS file require(['./ABCModule'], function(ABC) { ABC(1, 2); // returns 3; });
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.