Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RequireJs define parameters

In the official guide of RequireJs there's a define example:

define(["require", "./relative/name"], function(require) {
    var mod = require("./relative/name");
});

The first dependency, "require" is returned and inserted into the first parameter of the function.

Where does the second dependency goes?

Is it for the use of the require function that is executed inside? What does it return into "mod"?

like image 537
Gart Avatar asked Sep 05 '26 06:09

Gart


1 Answers

The second dependency will be the second parameter like so:

define(["require", "./relative/name"], function(require, mod) {
    console.log(mod);
});

See: http://requirejs.org/docs/api.html#defdep

like image 70
gazw Avatar answered Sep 07 '26 19:09

gazw



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!