Comments (3)
第一个问题,要更改 base 时,建议最好设置为绝对路径,比如 http://a.tbcdn.cn/js/app/xx/
非绝对路径时,和页面地址还有关系,比如:
assets/
js/
libs/
seajs.js
jquery.js
...
init.js
hello.js
css/
test.html
当
seajs.config({
base: 'assets/js/'
});
后,在 test.html 引用时,base 指向 http://your.com/path/to/assets/js/
建议让 base 始终指向 sea.js 所在目录
自己写的模块间,用相对路径引用,这样简单一致。
from seajs.
第二个问题,应该用 require,去掉 module.load 即可
假设有一个模块,必须依赖 a 和 b,在某些条件下依赖 c
则应该:
define(function(require, exports, module) {
var a = require('a');
var b = require('b');
if(some_condition) {
module.load('c', function(c) {
c.doSomeCoolThing();
});
}
exports.xx = 'xx';
});
module.exports 应该不能放在 module.load 的回调里,因此是同步执行,需要立刻返回的。放在 module.load 里,是异步的,异步回调里,一般不要去修改 module.exports
from seajs.
有了约定好办事!。。
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.