<!DOCTYPE html>
<html>
<head>
</head>
<body>
<span>body</span>
//通过链接引入seajs
<<script src="https://cdn.bootcss.com/seajs/3.0.2/sea.js"></script>
//执行seajs配置项,目的方便后面使用别名
<script src="./seajs-config-v1.js"></script>
<script>
//alias为seajs-config-v1里面所代表的的一个模块
seajs.use(["alias"] ,function(a){
var res = a.name
console.log(res)
});
</script>
</body>
</html>
seajs-config-v1.js代码
seajs.config({
"base": "./assets",
"alias": {
"alias": "a"//alias就代表assets文件夹的a.js模块
}
});
a.js模块代码
define(function(require, exports, module) {
var event = { // 对外提供接口
name: 'a',
doSomething: function() {
console.log('do')
}
}
module.exports = event
});