question:
The- CMD module relies on the second parameter deps, written in the define function and what"s the difference between the require written in the third parameter factory function? For example:
define("hi", ["jquery"], function (require, exports, module) {});
and
define("hi", function (require, exports, module) {
let jquery = require("jquery");
});
is also dependent on this module. What"s the difference between the two ways of writing? It is said that CMD is delayed, meaning that everything in the require in the factory function is loaded (but not executed), and then the factory function is executed first, and then the things in the require are executed where the require is encountered. But for the first one above, how does "deferred execution" be understood by ["jquery"]
?
- seajs.config? I feel they can replace each other. Here"s an example:
for the alias, in the picture, I can write it like this:
seajs.config({
paths: {
"jquery": "jquery/jquery/1.10.1/jquery"
}
});
define("hi", function (require, exports, module) {
let jquery = require("jquery");
});
for the paths, in the picture, I can write it like this:
seajs.config({
alias: {
"gallery": "xxxxxxxxxx/gallery"
}
});
define("hi", function (require, exports, module) {
let gallery= require("gallery");
});
so I feel very confused. I feel that their functions can actually be said to be the same. can you give an example that they cannot be substituted for each other?