这有可能吗?继续阅读与此相关的报告。

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

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

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

//  'underscore':'/resource/vendor/backbone.marionette/underscore',
'lodash':'/resource/vendor/lodash/lodash.min',

我收到以下错误...
Uncaught TypeError: Cannot read property 'vent' of undefined

lodash装得还可以,只是 Marionette 在提示。

似乎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   }

有什么建议吗?

最佳答案

对于其他任何人,答案是否定的。

Lodash 3.10.1很好,但是4.x版本从许多函数中删除了context选项,这破坏了Marionette

旧的方式是

    _.each(collection, iteratee, context);

新的方法是
_.each(collection, _.bind(iteratee, context));

但是到目前为止,在上面的requireJS设置中使用3.10.1到目前为止效果很好。

因此,在更新Marionette之前,您必须先保留4.x

关于javascript - 在主线 Marionette 2.4.4中将下划线1.8.3交换为下划线1.8.3,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35236516/

10-12 15:11