在页面的时候报个奇怪的dataHandle is undefined
dataHandle: function() {
//
},
simpleCategoryList: function() {
this.dataHandle();
}
在view 里面render 的时候用到, 本想先一次声明后面可以懒写个"this."
render: function() {
var _this = this,
categories,
simpleCategoryList = this.simpleCategoryList;
categories = simpleCategoryList();
}
稍注意一下,才发现 this in simpleCategoryList is window , 看来偷懒不得, 会心一笑。
render: function() {
var _this = this,
categories;
categories = this.simpleCategoryList();
}
还有另外一种方法,不过这种就超偏离原来的意图了。So ugly.
render: function() {
var _this = this,
categories;
categories = simpleCategoryList(_this); // so ungly
}
在simpleCategoryList里面还要接收_this再缓存起来,不要也罢:)