SeaJS项目完整实例【转】

index.html——主页面。

sea.js——SeaJS脚本。

init.js——init模块,入口模块,依赖data、jquery、style三个模块。由主页面载入。

data.js——data模块,纯json数据模块,由init载入。

jquery.js——jquery模块,对 jQuery库的模块化封装,由init载入。

style.css——CSS样式表,作为style模块由init载入。

sea.js和jquery.js的代码属于库代码,就不赘述,这里只给出自己编写的文件的代码。

html:

 

<!DOCTYPE  HTML>
<htmllang="zh-CN">
<head>
    <metacharset="UTF-8">
    <title></title>
</head>
<body>
<divid="content">
    <pclass="author"></p>
    <pclass="blog"><ahref="#">Blog</a></p>
</div>
<scriptsrc="./sea.js"data-main="./init"></script>
</body>
</html>

 

 javascript:

//init.js

define(function(require,
 exports, module) {
    var $ = require('./jquery');
    var data = require('./data');

    var css = require('./style.css');

    $('.author').html(data.author);

    $('.blog').attr('href',
 data.blog);

});
//data.js
define({
    author:'ZhangYang',
    blog:'http://leoo2sk.cnblogs.com'
});

 css:

.author{color:red;font-size:10pt;}

.blog{font-size:10pt;}

 

[1] SeaJS主页 – http://seajs.com

[2] SeaJS的GitHub库(可获取源码) – https://github.com/seajs/seajs

[3] SeaJS作者玉伯的博客 - http://lifesinger.wordpress.com/

 

转载于:https://www.cnblogs.com/jamesbd/p/3668645.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值