在主干牵线木偶2.4.4中交换下划线1.8.3 for lodash 4.2.1

Mat*_*son 6 javascript backbone.js underscore.js lodash marionette

这甚至可能吗?继续阅读相互矛盾的报告.

我有一个Marionette应用程序,刚刚升级到2.4.4.

如果我用lodash代替下划线 - 使用requireJS,

 map: {
  '*': {
    'underscore': 'lodash'
  }
},

//  'underscore':'/resource/vendor/backbone.marionette/underscore',
'lodash':'/resource/vendor/lodash/lodash.min',
Run Code Online (Sandbox Code Playgroud)

我收到以下错误...

Uncaught TypeError: Cannot read property 'vent' of undefined
Run Code Online (Sandbox Code Playgroud)

lodash装好了,只是牵牛花在抱怨.

似乎this在线上下文466是未定义的

 463 _proxyMethods: function() {
 464     _.each([ "vent", "commands", "reqres" ], function(system) {
 465       _.each(messageSystems[system], function(method) {
 466         this[system][method] = proxyMethod(this, system, method);
 467       }, this);
 468     }, this);
 469   }
Run Code Online (Sandbox Code Playgroud)

有什么建议?

Mat*_*son 9

对于任何看这个的人来说,答案是否定的.

Lodash 3.10.1很好,但是4.x发布已经context从许多功能中删除了选项,这些功能中断了Marionette.

旧的方式是

    _.each(collection, iteratee, context);
Run Code Online (Sandbox Code Playgroud)

新的方式是

_.each(collection, _.bind(iteratee, context));
Run Code Online (Sandbox Code Playgroud)

但到目前为止,使用3.10.1上面的requireJS设置非常好.

所以,直到Marionette更新,你必须推迟4.x