Open renhao opened 10 years ago
可以参考一下 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,这些方案会根据你的依赖关系进行模块加载。
你尝试把 jQuery 挂载在 window 变量下 $ = require('juqery');
比如:
var $ = require('juqery'); var Bootstrap = require('bootstrap');
这样写会报错,因为Bootstrap需依赖jquery; 请问这样的情况如何处理?