Comments (6)
场景一:
原来 require('biz/abc')
当 abc.js 有更新时,可以直接 require('biz/abc?t=20110425') 来更新
或者在 alias 配置里指定时间戳:
seajs.config({
'alias' : {
'abc': 'abc?t=20110425'
}
});
from seajs.
场景二:
当业务模块里有一堆文件需要更新时,推荐在 alias 配置里统一维护:
seajs.config({
'alias' : {
'a': 'a?t=20110425',
'b': 'b?t=20110425',
'c': 'c?t=20110425',
'd': 'd?t=20110425'
}
});
一个应用对应一个配置,一般来说,这样应该够用了。
from seajs.
场景三:
假设 seajs 一直用 1.0.0. 这时部分模块已经有新版了,比如 jquery 1.6 正式出来了。在不更新 seajs 时,如何将 jquery 模块更新到 1.6 呢?建议的方式是:
-
下载 jquery 1.6,自行封装成 seajs 的模块,重命名为 jquery-1.6.0-debug.js 和 jquery-1.6.0.js
-
将上面两个文件放到 sea.js 所在目录
-
在需要使用 jquery 1.6 的 app 里,指定 alias:
seajs.config({
'alias' : {
'jquery': 'jquery-1.6.0'
}
});
这样,该 app 下所有 require('jquery') 的地方,调用的将都是新版 jquery.
当然,也可以根据需求,自行决定 jquery 的 alias, 比如 jquery16 代码 1.6, 调用处再手动指定 require('jquery16')
from seajs.
场景四:
seajs 有更新了,比如从 1.0.0 更新到 1.1.0 了。这时请在页面中自行更新 sea.js 的引用路径。
这时要注意,如果自行更新过 modules,需要将自行更新过的 modules 复制过来,以保证所有 require 能正常引用到。
from seajs.
还有一种使用方式:
将 seajs 都部署到同一目录,全部带上版本号,比如:
libs/
sea-1.0.0.js
sea-1.1.0.js
jquery-1.5.2.js
jquery-1.6.0.js
...
sea-config.js
在 sea-config.js 里,指定默认类库:
seajs.config({
'alias': {
'jquery': 'jquery-1.6.0',
'underscore': 'underscore-1.2.0',
...
}
});
每次更新时,可以根据实际情况,选择是否更新 sea-config.js
在页面中引用 sea.js 的方式:
<script src="path/to/libs/??sea-1.0.0.js,sea-config.js"></script>
或者自己手动打包好,比如将 sea-1.0.0.js 和 sea-config.js 合并为 sea.js, 所有页面都引用 sea.js 即可
from seajs.
从简单易用,和现有常规用法考虑,目前依旧采用下面的方式提供 seajs 的下载包:
seajs/
0.9.0/
sea.js
sea-debug.js
jquery.js
jquery-debug.js
underscore.js
underscore-debug.js
...
1.0.0/
sea.js
sea-debug.js
jquery.js
jquery-debug.js
underscore.js
underscore-debug.js
...
from seajs.
Related Issues (20)
- 为什么要存在 require.async,和 seajs.use 的差别是?
- dist 目录中几个版本的区别是?(文档中没有找到说明)
- Failing CI
- Why should there be continuity_counter in TS?
- 谈谈这几天使用SeaJS 的感受 HOT 4
- 1
- css样式被覆盖的问题
- seajs不支持es6的语法? HOT 1
- 引入browser-polyfill支持promise不支持async let const? HOT 1
- Fix simple typo: themeselves -> themselves HOT 1
- could you please create 3.0.3 tag
- npm上的3.0.3是不是可用的? HOT 1
- 网络不稳定情况下通过seajs require.async加载的js文件部分请求失败,如何捕获异常并重新发送文件请求直至网络恢复?
- PullToRefresh中endReachedRefresh上拉加载后界面不会自动收回
- 某些安卓机型上通过sea.js引入的js文件里报的错,window.onerror不能捕获 HOT 2
- 将jquery从3.3.1升级到jquery3.5.1后,sea.js定义的模块不可用
- web端如何直接加载vue文件 HOT 3
- deleted
- 首页【乐研生物】点进去是黄网 HOT 2
- 有没有大佬分享下shellcode
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from seajs.