求解释一下下面几句代码:
wr.onopen = this._onWebRTCOpen.bind(this);
wr.onclose = this._onWebRTCClose.bind(this);
wr.onmessage = this._onWebRTCMessage.bind(this);
wr.onerror = this._onWebRTCError.bind(this);
解释一下这几句代码的作用即可,THX!
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
bind的知识点,百度一下不就行
首先
bind是ES5就有的。然后,意思就是将函数内部的
this改为传入的this,并对此函数备份,赋值给等号左边。别的我不清楚还有什么能解释的。传送门