fex-team / fis3-hook-amd

fis3 amd 模块化开发支持
BSD 2-Clause "Simplified" License
25 stars 9 forks source link

请问fis3的amd怎么声明js之间的依赖关系? #21

Open sabver opened 8 years ago

sabver commented 8 years ago

如题,比如bootstrap是依赖jquery的,我现在的fis-conf.js是这样子写的: fis.hook('amd', { paths:{ 'c':'component_modules', 'common':'components/common', 'hcommon':'components/h+common', 'com':'components', 'text':'lib/text.js', 'css':'lib/css.js', 'domReady':'lib/domReady', 'jquery': 'component_modules/jquery2.1.4/jquery.min', 'avalon': "component_modules/avalon/avalon.shim",
'bootstrap':'component_modules/bootstrap3.3.5/bootstrap.min', 'toastr':'component_modules/toastr/toastr', 'toast':'components/common/js/toast', 'validate':'components/common/js/validate_mvvm', 'mock':'component_modules/mock/mock', 'swal':'component_modules/sweetalert/sweetalert.min', 'swal_css':'component_modules/sweetalert/sweetalert.css', 'layer':'component_modules/layer/layer.min', 'icheck':'component_modules/iCheck/icheck.min', 'icheck_css':'component_modules/iCheck/custom.css', }, //声明依赖 shim:{ 'jquery':{ exports:'jquery', }, 'bootstrap':['jquery'], 'layer':['jquery'], 'toastr':['jquery'], 'icheck':['jquery'] }, }); 然后我在引用的时候: require(['jquery','boostrap'],function(){});

页面就会报错,原因就是因为bootstrap里面是有声明到依赖的,所以程序就终止了,请问怎么解决?

PS:shim那里我曾经这样子写: shim:{ 'bootstrap':{ deps:['jquery'] } } 好像也没有什么作用....

sabver commented 8 years ago

Got Error: shim.deps.forEach is not a function while parse [/component_modules/bootstrap3.3.5/bootstrap.min.js]. 我改为shim:{ 'bootstrap':{ deps:['jquery'] } } 之后就报上面的错了