Sea.js基础知识
来源:互联网 发布:kali linux破解wifi 编辑:程序博客网 时间:2024/06/11 21:10
目录结构
所有源码都存放在 GitHub 上:seajs/examples,目录结构为:
examples/ |-- sea-modules 存放 seajs、jquery 等文件,这也是模块的部署目录 |-- static 存放各个项目的 js、css 文件 | |-- hello | |-- lucky | `-- todo `-- app 存放 html 等文件 |-- hello.html |-- lucky.html `-- todo.html
我们从 hello.html
入手,来瞧瞧使用 Sea.js 如何组织代码。
在页面中加载模块
在 hello.html
页尾,通过 script
引入 sea.js
后,有一段配置代码:
// seajs 的简单配置seajs.config({ base: "../sea-modules/", alias: { "jquery": "jquery/jquery/1.10.1/jquery.js" }})// 加载入口模块seajs.use("../static/hello/src/main")
sea.js
在下载完成后,会自动加载入口模块。页面中的代码就这么简单。
模块代码
这个小游戏有两个模块 spinning.js
和 main.js
,遵循统一的写法:
// 所有模块都通过 define 来定义define(function(require, exports, module) { // 通过 require 引入依赖 var $ = require('jquery'); var Spinning = require('./spinning'); // 通过 exports 对外提供接口 exports.doSomething = ... // 或者通过 module.exports 提供整个接口 module.exports = ...});
上面就是 Sea.js 推荐的 CMD 模块书写格式。如果你有使用过 Node.js,一切都很自然。
0 0
- Sea.js基础知识
- Sea.js
- sea.js
- Sea.js
- sea.js
- sea.js
- sea.js
- sea.js
- sea.js开发:快速入门sea.js
- 开源---Sea.js
- sea.js介绍
- sea.js 原理解析
- sea.js基础学习
- Sea.JS入门教程
- Sea.js简单使用
- sea.js学习收集
- sea.js基础
- Sea.js入门教程
- 使用API创建窗口
- test17
- GlassFish 设置domain的默认应用(通过ip:port访问)
- c语言时间函数
- UML建模
- Sea.js基础知识
- test18
- POJ 2017 解题报告
- editor does not contain a main type的解决方案
- test19
- Spring定时任务的简单例子(转载)
- spring与junit结合测试
- test20
- 凤求凰·琴歌