Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mod.js中的js文件之间的依赖关系该如何处理呢? #10

Open
renhao opened this issue Aug 16, 2014 · 2 comments
Open

mod.js中的js文件之间的依赖关系该如何处理呢? #10

renhao opened this issue Aug 16, 2014 · 2 comments

Comments

@renhao
Copy link

renhao commented Aug 16, 2014

比如:

var $ = require('juqery');
var Bootstrap = require('bootstrap');

这样写会报错,因为Bootstrap需依赖jquery;
请问这样的情况如何处理?

@hefangshi
Copy link
Member

可以参考一下 https://github.com/hefangshi/modjs-autoload-demo

比如我们在页面中只要require('main')

https://github.com/hefangshi/modjs-autoload-demo/blob/master/index.html#L28-L30

在页面加载时,就会先加载main.js中声明的各种依赖模块

https://github.com/hefangshi/modjs-autoload-demo/blob/master/modules/main.js#L3-L9

另外你是否是直接独立使用的mod.js?mod.js是不能独立使用的,必须配合后端静态资源管理方案,如fis-plus, jello等,或者纯前端的静态资源管理方案fis-pure,这些方案会根据你的依赖关系进行模块加载。

@BelinChung
Copy link

你尝试把 jQuery 挂载在 window 变量下
$ = require('juqery');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants