Requirejs also has a lot of good features, but may not be very common, the following describes the following features:
1. Map parameters
map: { "new_aaa": {"CCC": "MOUDLE/CCC/CCC1" }, "Old_aaa": { "CCC": "MOUDLE/CCC/CCC2" }, "*": { "CCC": "MOUDLE/CCC/CCC3" } }
The role of map is to facilitate the user to configure different versions of the same module, such as the site has a part of the revision, need to upgrade to the latest version of jquery, but the page may not be revised with the newest version of jquery is not compatible with, or need to use the old version of jquery, this time to use the map.
Take the above code example, NEW_AAA for a new development module, OLD_AAA for an old module, * for the remaining modules, three modules are required to refer to the CCC module, but they want the CCC may be a little different, so they each quoted different CCC, said here everyone to feel strange , does this not define the three CCC modules? It's not convenient at all. Is that really the case? Not also not also. Let me say the advantages of map:
① module names are unified, such as jquery, where all dependent JQ can be directly ["jquery"] without some place ["jquery-1.10.1"],["jquery-1.7.1"].
② convenient modification, for example, I suddenly have a new version of JQ, the direct config to modify it, and do not deliberately find the place to modify the module to modify.
Specific code to see the demo bar
Demo download
Primary knowledge Requirejs (II.)