gpt4 book ai didi

javascript - ES6 如何在另一个上下文中的类中获取 _this

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:58:49 25 4
gpt4 key购买 nike

<分区>

我一直在搜索,但找不到以 ES6 方式解决这个问题的合适方法。

class MyClass {
// i can't event decalre _this/_self here
constructor() {
setTimeout(function(){
// other work..
hiUser(); // this.hiUser() or //_this.hiUser() not working
},1000);
}
hiUser(){
alert('Hi');
}
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com