We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
版本:2.9.1
复现方式:
import { createWebsocket } from 'qq-guild-bot'; class Test { constructor(ws: any) { ws.on('READY', this.test); } test() { console.log(this); } } const test = new Test(createWebsocket(/* 配置文件略 */)); test.test();
输出结果:Ready回调Test.test()输出的this为WebsocketClient,而非test实例。
所以是不是应该改成绑定为对应的类实例会好一些?因为一些时候需要将功能封装,不这样的话会很难受。
The text was updated successfully, but these errors were encountered:
你应该传入this.test.bind(this)
Sorry, something went wrong.
Joy-Wang
No branches or pull requests
版本:2.9.1
复现方式:
输出结果:Ready回调Test.test()输出的this为WebsocketClient,而非test实例。
所以是不是应该改成绑定为对应的类实例会好一些?因为一些时候需要将功能封装,不这样的话会很难受。
The text was updated successfully, but these errors were encountered: