我在 ESRI 的 Web AppBuilder 环境(使用 ESRI Javascript 3.x API)中使用 dojo。
无论如何,我创建了一个按钮,并且在按钮的 onClick 方法中,我希望能够使用 lang.hitch 调用另一个函数(以将函数保持在范围内)。但是被调用的函数带了一个参数,我好像传不进去,只能调用函数,像这样。
this.myDialogBtn1 = new Button({
label: "Create New Location",
disabled: false,
onClick: lang.hitch(this, this._createNewLocation)
}).placeAt(this.createNewLoc)
当然,我的 _createNewLocation 函数需要带一个参数,就像这样。
_createNewLocation(param){...do stuff}
我不确定如何将该参数传递给 onClick 方法。像这样添加参数是行不通的。它抛出一个类型错误。有任何想法吗?
lang.hitch(this, this._createNewLocation(param))