我的应用中有这样的代码:
observers: [
'_dataGenericObserver(userData.generic)',
],
// If this.userData.generic.id is set, then the register tab is
// NOT visible. In this case, the selected tab mustn't be "register"...
_dataGenericObserver: function(){
if (this.userData.generic.id){
this.selected = 'login';
} else {
if (this.defaultRegister) {
this.selected = 'register';
} else {
this.selected = 'login';
}
}
},
这样安全吗?或者我应该总是这样做:
observers: [
'_dataGenericObserver(userData.generic)',
],
// If this.userData.generic.id is set, then the register tab is
// NOT visible. In this case, the selected tab mustn't be "register"...
_dataGenericObserver: function(generic){
if (generic.id){
this.selected = 'login';
} else {
if (this.defaultRegister) {
this.selected = 'register';
} else {
this.selected = 'login';
}
}
},
...?
在某些情况下,我注意到应用程序的其他部分,如果我在_someFunc(value.subvalue)
上有一个观察者,然后有_someFunc: function( subValue)
,则在subValue
函数中设置,而this.value.subValue
ISN'吨。但是,我无法复制它 - 抱歉。
问题:
this.*
?subValue
被设置为函数参数,但不在this.value.subValue
?