seajs第一节,seajs基本使用

什么是seajs,它是干什么使用的,可以去网上搜索一下,

官网:http://seajs.org/docs/

基本使用seajs

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>seaJS学习第一节</title>
//加上 seajsnode 值,可以让 sea.js 直接获取到自身路径,而不需要通过其他机制去自动获取。这对性能和稳定性会有一定提升,推荐默认都加上。
<script src="modules/sea/sea.js" id="seajsnode"></script> <script>
    //seajs.use()中的js路径默认是在sea.js所在的目录搜索,所以加上./
    //seajs.use(a,b),有两个参数a加载模块的路径,b回调函数 b(ex) 中的ex参数是demo.js中的exports seajs.use('./static/demo1/demo.js',function(ex){ ex.show(); }); </script> </head> <body> </body> </html>
demo.js
//require, exports, module 这三个参数相当于关键字,不允许修改
define(function(require,exports,module){  function show(){ alert("我是demo"); }
  //exports : 对外提供接口对象, exports.show
= show; })
原文地址:https://www.cnblogs.com/fan-fan/p/3722340.html