javascript - 如何正确引用类constructor()中声明的数据?
问题描述
这是代码快照:
class UIController {
constructor() {
let eleNodes = new EleNodes()
this.idsAndClasses = eleNodes.idsAndClasses
this.nodes = eleNodes.nodes
}
async OpenCloseForm() {
let formContainer = this.nodes.solcomForm
//...other code
}
}
当我稍后OpenCloseForm
在单击时指定为函数时,this
不再引用 che 类,而是按下按钮this.nodes
的变为的上下文。this
这里是点击设置:
//this in this case references to the object setup in yet another class
//where I also call this event handler
this.uiCtrl.solcomForm.on("click", this.uiCtrl.OpenCloseForm)
有没有办法引用回类中的实际数据?
ps:我已经查看了标记的问题,它确实缺少上下文,在这种情况下使用类而不是函数,所以我无法从另一个上下文中得出解决方案。
解决方案
推荐阅读
- regex - 正则表达式:匹配两个或多个前面的标记?
- azure - 具有 ID 的 Terraform 资源已存在
- reporting-services - SSRS 2016 Oracle ODP.NET 间歇性 ORA-12571
- r - 抓取网页(使用 R),其中所有元素都放置在
标签 - javascript - 使用 javascript 确定最后访问的页面是否是我的网站
- git - git SHA 可以作为电子设备软件版本的一部分显示吗
- prestashop - 在 Prestashop 行政办公室的订单表中为承运人列添加颜色
- node.js - 要求 mongoose 模型导致 Uncaught (in promise) TypeError: Cannot read property 'find' of null
- reactjs - React useReducer 和 context:如何提供状态选择器?
- javascript - 为什么我在 Squarespace 中收到错误 Y Not Defined Error