seajs.config({
alias: { 'jquery': 'jquery/jquery/1.10.1/jquery' }
});
define(function(require, exports, module) {
//引用jQuery模块
var $ = require('jquery');
});
seajs.config({
//设置路径
paths: {
'gallery': 'https://a.alipayobjects.com/gallery'
},
// 设置别名,方便调用
alias: {
'underscore': 'gallery/underscore'
}
});
seajs.config({
// 变量配置
vars: {
'locale': 'zh-cn'
}
});
define(function(require, exports, module) {
var lang = require('./i18n/{locale}.js');
//=> 加载的是 path/to/i18n/zh-cn.js
});
seajs.config({
map: [
[ '.js', '-debug.js' ]
]
});
define(function(require, exports, module) {
var a = require('./a');
//=> 加载的是 path/to/a-debug.js
});
// 在老浏览器中,提前加载好 ES5 和 json 模块
seajs.config({
preload: [
Function.prototype.bind ? '' : 'es5-safe',
this.JSON ? '' : 'json'
]
});
seajs.config({
preload: 'a'
});
// 在加载 b 之前,会确保模块 a 已经加载并执行好
seajs.use('./b');
seajs.config({
charset: function(url) {
// xxx 目录下的文件用 gbk 编码加载
if (url.indexOf('http://example.com/js/xxx') === 0) {
return 'gbk';
}
// 其他文件用 utf-8 编码
return 'utf-8';
}
});
// 加载一个模块
seajs.use('./a');
// 加载一个模块,在加载完成时,执行回调
seajs.use('./a', function(a) {
a.doSomething();
});
// 加载多个模块,在加载完成时,执行回调
seajs.use(['./a', './b'], function(a, b) {
a.doSomething();
b.doSomething();
});
seajs.use(['jquery', './main'], function($, main) {
$(document).ready(function() {
main.init();
});
});
var bootstrap = ['bootstrap.css', 'bootstrap-responsive.css', 'bootstrap.js'];
seajs.use(bootstrap, function() {
//do something
});
Object > http://seajs.org/docs/assets/main.js: x > https://a.alipayobjects.com/jquery/jquery/1.10.1/jquery.js: x > __proto__: Object
seajs.resolve('jquery');
// => http://path/to/jquery.js
seajs.resolve('./a', 'http://example.com/to/b.js');
// => http://example.com/to/a.js
// 在 http://example.com/js/a.js 的 factory 中:
require.resolve('./b');
// => http://example.com/js/b.js
// 在 http://example.com/js/a.js 的 factory 中:
require.resolve('../c');
// => http://example.com/c.js
// 假设 base 路径是:http://www.aseoe.com/assets/
// 在模块代码里:
require.resolve('gallery/jquery/1.9.1/jquery');
// => http://www.aseoe.com/assets/gallery/jquery/1.9.1/jquery.js
//sea.js的路径,即 base 路径,相对于当前页面
<script src="../actjs/assets/sea-modules/seajs/2.1.1/sj.js"></script>
<script type="text/javascript">
//配置Seajs
seajs.config({
alias: {
//顶级标识,基于 base 路径
'actjs': 'actjs/core/0.0.7/core.js',
// => http://
'position': 'actjs/util/0.0.2/position.js'
}
});
seajs.config({
alias: {
//普通路径,相对于当前页面
'affix': '../../actjs/assets/widget/src/widget-affix.js',
//相对标识,相对于当前页面
'init': './src/init.js'
}
});
</script>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有