我正在构建骨干木偶应用程序。在木偶中,您可以执行以下操作:
Marionette.Application.extend({
regions: {
mainRegion: function(){return someCondition?"#A":"#B"},
otherRegion: "#something"
}
})
我正在尝试使用自定义对象在我的应用程序中实现这一点。实现此目标的最佳方法是什么?目前,我正在检查每个值:
if(typeof obj == "function") {
this.data.obj = obj();
}
else {
this.data.obj = obj;
}
或相应的?:表达式。有没有更简单的方法可以做到这一点?
Underscore具有一种result
完全可以满足您需求的方法(请参阅http://underscorejs.org/#result)
您可以在此处找到实现:http : //underscorejs.org/docs/underscore.html#section-128
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句