Why use Sea.js?
Sea.js Simple, natural code writing and organizing methods
Good compatibility
Technology is more mature, the use is more common.
Directory structure:
examples/|--sea-modules Storage Seajs, jquery and other files, which is also the deployment directory of the module |--static storage of each project JS, css file | |--Hello | |--Lucky | '--todo '--the app holds HTML and other files |--hello.html |--lucky.html '--todo.html
The module is documented in the page:
in hello.html
footer, through script
introduction of sea.js
, there is a configuration code:
Seajs Simple Configuration Seajs.config ({base: "). /sea-modules/", alias: {" jquery ":" Jquery/jquery/1.10.1/jquery.js "}})//Load ingress module Seajs.use (".. /static/hello/src/main ")
sea.js
After the download is complete, the Portal module is loaded automatically.
code module:
This mini-game has two modules spinning.js
and main.js
follows a unified notation:
All modules are defined by the Define define (function (Require, exports, module) {///via require to introduce a dependent var $ = require (' jquery '); var Spinning = require ('./spinning '); Externally provided via exports interface exports.dosomething = ...//or through Module.exports provide the entire interface Module.exports = ...});
Above is the Sea.js recommended CMD module writing format.
5 minutes to get started Sea.js