手动初始化
This commit is contained in:
parent
c942b7673a
commit
09dc671216
@ -188,6 +188,7 @@ const handleReceive = async () => {
|
|||||||
};
|
};
|
||||||
// 事件监听
|
// 事件监听
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
peer.init();
|
||||||
peer.on("open", ((event: CustomEvent) => {
|
peer.on("open", ((event: CustomEvent) => {
|
||||||
myId.value = event.detail;
|
myId.value = event.detail;
|
||||||
const sign = getUrlParam("sign");
|
const sign = getUrlParam("sign");
|
||||||
|
@ -21,7 +21,9 @@ class Peer extends EventTarget {
|
|||||||
constructor(sign: string) {
|
constructor(sign: string) {
|
||||||
super()
|
super()
|
||||||
this.sign = sign
|
this.sign = sign
|
||||||
this.peer = new PeerJs(sign2peerid(sign))
|
}
|
||||||
|
public init() {
|
||||||
|
this.peer = new PeerJs(sign2peerid(this.sign))
|
||||||
this.peer.on('open', (id) => {
|
this.peer.on('open', (id) => {
|
||||||
console.log('peer open', id)
|
console.log('peer open', id)
|
||||||
this.id = id
|
this.id = id
|
||||||
|
Loading…
Reference in New Issue
Block a user