Uncaught (in promise) TypeError: Failed to execute 'createOffer' on 'RTCPeerConnection': Illegal invocation

这个错误Illegal invocation我理解为无法新建它的引用

如:

1
2
3
const localPeerConnection = new RTCPeerConnection(servers);

const { createOffer } = localPeerConnection;

有时候我们想抽取对象的方法简便使用,易于阅读
但javascript对象内部指针this此时可能会指向window,导致未知错误。

所以,有些必要书写我们还是老实一点

1
localPeerConnection.createOffer(...)
#

Comments

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×