Relative paths with RequireJS modules/packages

后端 未结 4 1167
悲哀的现实
悲哀的现实 2021-01-30 02:58

I\'m fairly new to RequireJS and I\'ve run into a bit of a problem. I\'ve written a little framework built on Backbone using RequireJS and I want it to be re-usable in different

4条回答
  •  长发绾君心
    2021-01-30 03:12

    This worked for me, adding a "./" prefix to the module names:

    define(function (require, exports, module) {
        exports.createDash = function (dash, element) {
            require([ './dash/dash.model', './dash/dash.view' ], function (DashModel, DashView) {
                return new DashView({
                    model : new DashModel(dash),
                    el : element ? element : window
                });
            });
        };
    });
    

提交回复
热议问题