Primary knowledge Requirejs (II.)

Source: Internet
Author: User

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.)

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.