【发布时间】:2012-03-31 17:51:13
【问题描述】:
我想知道如何在 mootools 中将 self 传递给其他对象, 我正在尝试基于 mootools 类声明构建类,但我注意到当我使用它时我无法使用它发送对象本身,它发送 DOMWindow 而不是 World 或对象本身,以下是我的代码,
var World = new Class({
....
initialize: function(rows, ...) {
// build grass // can only have one grass per location
this.grassList = Enumerable.Range(0, rows).SelectMany(
function(row) {
return Enumerable.Range(0, columns).Select(
function(column) {
return new Grass(this, new Location(row, column), quantityOfGrass, maxQuantityOfGrass, growRateOfGrass)
})
}).ToArray();
}
....
}
我在这个位置遇到问题,
return new Grass(this, new Location(row, column), quantityOfGrass, maxQuantityOfGrass, growRateOfGrass)
因为它不起作用,我检查了,
return new Grass(World, new Location(row, column), quantityOfGrass, maxQuantityOfGrass, growRateOfGrass)
我使用的是 linq.js 和 mootools 都不起作用,有人可以指导我吗?
【问题讨论】:
标签: c# javascript json mootools object-initializers