Seajs超简单使用示例

以下示例很简单,就是在页面打印出seajs。(适合刚接触seajs五分钟的初学者,大神请绕路哈)

文件组织结构:

     --myexsample

      --js 

        --module

          --write.js

        --seajs

          --sea.js

      --index.html

 

index.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<div id="content"></div>
<script src="js/seajs/sea.js"></script>
<script>
seajs.config({})//相关配置
seajs.use("module/write");//加载write.js模块,需要注意路径的正确填写
</script>
</body>
</html>

write.js

// JavaScript Document
define(function(require){//模块定义
    var container = document.getElementById("content");
    container.innerHTML = "seajs";
    })

 

运行结果:

 

备注:这个小示例只有很少的内容,只为了显示seajs的文件组织和简单实用。

具体内容请参考相关开发文档:http://seajs.org/docs/#docs

posted @ 2014-01-08 16:52  Joy Ho  阅读(409)  评论(0编辑  收藏  举报