我想把一些代码打包成组件到处使用,大概是这样的:
m1.js
define([ "backbone" ], function ( backbone ) { return Backbone.View.extend({ render: function () { var This = this; this.$el.html(this.template(this.model.attributes)); return this; } }); });
m2.js
define([ "backbone","m1" ], function ( backbone,m1 ) { return Backbone.View.extend({ render: function () { var This = this; this.$el.html(new m1().render().$el); return this; } }); });
然后把我这两个文件打成一个包,pack.js,我希望在别的文件中调用它,比如:
m3.js
define([ "backbone","pack" ], function ( backbone,pack ) { return Backbone.View.extend({ render: function () { var This = this; this.$el.html(new pack().render().$el); return this; } }); });
结果发现pack没有加载成功,是空对象,请问有办法解决吗?
付费偷看金额在0.1-10元之间
一周热门 更多>