JavaScript module loading framework sea. js Learning 1. javascriptsea. js

Source: Internet
Author: User

JavaScript module loading framework sea. js Learning 1. javascriptsea. js

Summary of sea. js Learning

File directory structure

/Sea. js http://seajs.org/docs/#downloads

/Sea/jquery-sea.js http://jquery.com/download/

/Sea/sea_config.js

/Sea/home. jsdata. js

/Sea/data. js


1.html Page code file

<Style>. ch {height: 200px; width: 200px; background: # ccc ;}</style> <div class = "cl"> </div> <! -- Introduce the sea. js file --> <script src = "/sea. js"> </script> <! -- Introduce sea_config.js configuration file --> <script src = "/sea/sea_config.js"> </script> <script type = "text/javascript"> seajs. use (['jquery ', 'home'], function (a, B) {// alert (B. foo); // call the foo attribute B in home. init (); // call the init interface B in home. all (); // call the all interface in home}) </script>

2. sea_config.js configuration file

Seajs. config ({// alias configuration alias: {'jquery ':'/sea/jquery-sea', 'Home': '/sea/home', 'data ': '/sea/data'}, // path configuration // paths: {// 'gallery': 'https: // a.alipayobjects.com/gallery '//}, // variable configuration // vars: {// 'locale': 'zh-cn' //}, // ing configuration // map: [// ['HTTP: // example.com/js/app/', 'HTTP: // localhost/js/app/'] //], // pre-add-on // preload: ['jquery', 'home'], // debug mode: true, // Sea. js basic path // base: 'http: // example.com/path/to/base/', // file encoding charset: 'utf-8 '});

3. home. js module File

Define (function (require, exports, module) {var data = require ('data'); // load the data module data. js function wo () {// internal function, calling alert ("load $") ;}; alert (data. blog); // directly execute the function module. exports = {// interface foo: 'hello' provided by the current module, // attribute init: function () {// interface initwo (); // execute the internal function $ (". cl "). addClass ("ch") ;}, all: function () {// interface all alert (data. author) ;}}; console. log (require. resolve ('jquery '); // require. resolve returns the absolute path after alias file resolution });

4. data. js module File

define({    author: 'ZhangYanpo',    blog: 'http://www.ktuo.cn'});



JavaScript recommends a good site for JavaScript to learn how to use,

1. www.w3school.com.cn/javascript/ basic learning

2. Right-click any website, view the source code, and then view their js principles.
From a three-stream website, the ranking is low => medium websites => portal websites

3. after jq core is completed, JavaScript is no longer difficult, but cannot be thought out. (the last time I made a three-dimensional 3D sphere for others with shadow effects. all are generated using code. I have also done JS mmorpg games, ajax + flash socket, but it always feels a little slow ............)

How Should javascript execute a function during page loading?

<Script type = "text/javascript">
Function finish (){

Alert ('hello ');
}
</Script>
<Body onload = "finish ()">

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.