SeaJS入门教程系列之完整示例(三)
来源:互联网 发布:matlab将矩阵变成一列 编辑:程序博客网 时间:2024/05/16 08:18
转载:原文链接
这篇文章主要介绍了SeaJS入门教程系列之完整示例,演示了一个完整的SeaJS开发例子,需要的朋友可以参考下
一个完整的例子
上文说了那么多,知识点比较分散,所以最后我打算用一个完整的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><html lang="zh-CN"><head> <meta charset="UTF-8"> <title></title></head><body><div id="content"> <p class="author"></p> <p class="blog"><a href="#">Blog</a></p></div><script src="./sea.js" data-main="./init"></script></body></html>
javaScript
init.js
//init.jsdefine(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
//data.jsdefine({ author: 'ZhangYang', blog: 'http://blog.codinglabs.org'});
css
.author{color:red;font-size:10pt;}.blog{font-size:10pt;}
运行效果如下:
0 0
- SeaJS入门教程系列之完整示例(三)
- SeaJS入门教程系列之完整示例(三)
- SeaJS入门教程系列之完整示例(三)
- SeaJS入门教程系列之使用SeaJS(二)
- SeaJS入门教程系列之SeaJS介绍(一)
- SeaJS入门教程系列之使用SeaJS(二)
- SeaJS入门教程系列之SeaJS介绍(一)
- SeaJS入门教程系列之使用SeaJS(二)
- SeaJS入门教程系列之SeaJS介绍(一)
- SeaJS入门教程系列之使用SeaJS(二)
- Seajs源码解析系列(三)
- [转]coolfire黑客入门教程系列之(三)
- seajs入门教程
- seajs入门教程
- grunt 入门教程五:完整示例(完结篇)
- MVC5 + EF6 完整入门教程三
- MVC5 + EF6 完整入门教程三
- MVC5 + EF6 完整入门教程三
- [LeetCode] 42. Trapping Rain Water
- config.c 或者config.s 依照os的不同而config.X 的X也是不同的:
- bzoj 1711: [Usaco2007 Open]Dining吃饭 (最大流)
- PHP正则路由的实现原理
- VS编译cocos2dx,链接库问题
- SeaJS入门教程系列之完整示例(三)
- Linux实战教学笔记13-定时任务补充
- RF与Python
- Java学习之反射和注解
- Log4j 2 Introduction
- 利用Editor.md构建Markdown富文本编辑器
- 八皇后 —— 递归
- oracle字符集
- log4j2 在java web中的使用