未捕获的TypeError:无法读取未定义的属性"app" [英] Uncaught TypeError: Cannot read property 'app' of undefined
问题描述
我有一个复合视图:
var resultView = Marionette.CompositeView.extend({
template : ResultPanel,
itemView : ResultItemView,
initialize : function() {
...
},
itemViewOptions : {
app : this.options.app
},
我只想将此视图的app属性分配给itemView的app属性.因此,我可以从其他视图使用此视图的应用程序.但是我收到此错误:Uncaught TypeError:无法读取未定义的属性"app".我究竟做错了什么?有另一种方法可以做到这一点吗?
I just want to assign this view's app property to itemView's app property. So i can use this view's app from other view. But I'm getting this error: Uncaught TypeError: Cannot read property 'app' of undefined. What am i doing wrong? Is there another way in order to do this?
推荐答案
可能性#1: 代码执行时尚未设置this.option.
possiblity #1: this.option is not yet set when your code executes.
可能性#2: 也许这"不是您所期望的. 分配var = this; 之前并使用"that"代替"this".
possibility #2: maybe 'this' is not what you expect it to be. assign var that = this; before and use 'that' instead of 'this'.
或分配var _options = this.options;在extend()之前,并在扩展中使用_options.
or assign var _options = this.options; before extend() and use _options in the extend.
这篇关于未捕获的TypeError:无法读取未定义的属性"app"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!