通常当我们使用this
时,它指的是类。我该如何使这个指的是函数中的类?
但是在这种情况下,this
是dataChannel
,我怎样才能让this
再次指VideoService
?谢谢
export class VideoService {
dataChannel:any;
setupPeerConnection() {
this.dataChannel.onopen = this.dataChannelStateChanged;
}
dataChannelStateChanged() {
// here this = dataChannel, how can I let this = VideoService
console.log(this);
}
}
谢谢sfsq! –