javascript - what is the difference between require and require -


What is the difference between the two without almonds?

is required (requires 'module' (['module']);

edited

Which are nested:

defined (function () {requires ('module');}

< P> define (function () {required (['module'])}}

returns a needjs error (which suggests using the ladder) .

The reason I am asking,

I

file: principium.js

>

  / ** * The main module which provides Defines, / / ​​defines the public interface for piimo (function (requirement) {convert = needed ('principium / convert'); // return module value. Return {convert: convert};} );  

The Library Module gives the main module.

File: lib / main.js

  Define (function () {// use special top-level almonds, get synchronous // to get the last module value When required, and export it as a public // value. Requires return ('Principium'); });  

In this example, it uses almonds for the requirement of principium ( returns required ('principium') ) I hope the exporter library object to back it up.

But I do not use almonds and require the ('principium') syntax error, and if I use ([' Instead, the exported Library Object does not return.

Exported Library Object, I mean return {convert: convert}; back to Principium.js .

edit

How do I use nested properly So that:

Edit

I solved it, but I do not know How it works, I used to add almonds and it was magical.

"Include": ["../bower_components/almond/almond", "Lib / Main "]

and restructured

file: lib / main.js

  (define [], Function () {Return Required ('Principium');});  

This is the "latter", why F it climbs up to reach to reach the section after the two options, ladders are not, which is a thing that you height otherwise impossible or down.

That way, "the more you know" the same: if you are using need.js, then you just need a module: Dependency Load to run the required.js function Therefore, syntax is:

  is required (['dependency 1', 'dependency 1', ...], function codatoron (Dipa 1, dipa 2) { ...});  

Your job is dependent on code dependency 1 , etc., and therefore you need to "load" that code, and it should be used on the variable The function that is provided in the form should also be run.

Just in a module it is required without the need for anything, there is no requirement, which is required. JS can tell, so it throws an error.


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -