Requirejs Study Notes

Source: Internet
Author: User

Main.js

Requirejs.config ({

BASEURL: ' Scripts/lib ',
Paths: {

App: '.. /app ',
Style: '. /.. /style ',
Resources: '. /.. /resources ',
CSS: ' Require-css/css ',
jquery: ' jquery ',

Formbootstrap: ' Formvalidation/dist/js/framework/bootstrap ',
Formvalidation: ' Formvalidation/dist/js/formvalidation ',

ICheck: ' Icheck/icheck ',

Text: ' Require-text/text '

},
Shim: {
Formvalidation: {
Deps: [' jquery ']
},
formbootstrap:{
Deps: [' formvalidation ']
},
ICheck: [' jquery ']
},
Map: {}

});


Baseurl:configure loading modules form that directory.

Put all third-party dependencies, such as jquery, in the Lib folder. BaseURL is set to Lib,requirejs based on this directory to find dependent modules. If not set, BaseURL defaults to the path where the specified file (specified in HTML) is Data-main.


Paths:the paths config is only for setting up root paths for module IDs. Paths configuration is used only to set the root path of the corresponding module ID
-app: '.. /app '
The declaration relies on require (["App/common"]: when, in fact, is looking for. /app/common.js.

-Text: ' Require-text/text '

For plug-ins, such as text, there are the following statements: such as written in map:*, cannot be loaded under node successfully.

-there is a saying, not the path that begins with the item declared in paths, not affected. But in actual use, will still be substituted.

For example, require ([".. /.. /app/common "], where the app will be substituted for: /app


Map:mapping One module ID to another one. When you want to specify multiple versions of the same resource, you should use map to load multiple paths
-' * ': for all module loads, use this map configuration. If there is a more granular map configuration, it will take precedence over the "*" configuration.
For example:
' * ': {' jquery ': ' Jquery-private '},
' Jquery-private ': {' jquery ': ' jquery '}
' jquery ': ' jquery-private ': means that all modules rely on ' jquery ' and actually rely on ' jquery-private '
' Jquery-private ' relies on the real jquery module when it comes to "jquery." If you do not write this line, you will form a dependency loop.

Requirejs Study Notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.