Seajs Shim Plugin: The difference between a plug-in that solves a non-CMD specification and sea

Source: Internet
Author: User

The modules in Seajs obey the CMD specification by default, but in reality there are a lot of common JavaScript libraries such as jQuery, underscore, etc. Using the shim plugin, these ordinary JS files can be converted to a CMD module, which can be used normally in SEAJS.

Seajs.config ({  plugins: [' Shim ']});

Once activated, alias configuration items can be configured to accept them shim Object .

Seajs.config ({  //Activate shim plugin  plugins: [' shim '],  //shim config Item  alias: {    //jquery shim configuration    ' jquery ': {      src: ' lib/jquery-1.9.1.min.js ',      exports: ' jquery '    },    //jquery.easing plugin's shim configuration    ' Jquery.easing ': {      src: ' lib/jquery.easing.1.3.js ',      deps: [' jquery ']}}}  );
shim Object

shim Objectis an object:

' key ': {    src:string,    deps:array,    exports:string | Function  }

srcis a string that represents the file path.

depsis an array that specifies the module dependency .

exportsIndicates require(key) which global variable should be returned, such as jquery, which returns a jQuery global variable. exportsIt can also be a function:

' jquery ': {   src: ' lib/jquery-1.9.1.min.js ',   exports:function () {   return jquery.noconflict ();}  }

With the shim plugin, you can load any non-CMD module.

Description: Generally used in config, first activate plugins: [' Shim '], and then configure the plugins to be referenced in alias, such as jquery.

Original http://www.k68.org/?p=1192

Seajs Shim Plugin: The difference between a plug-in that solves a non-CMD specification and sea

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.