diff --git a/src/chat.js b/src/chat.js index 3734432..0c9eb3a 100644 --- a/src/chat.js +++ b/src/chat.js @@ -185,9 +185,10 @@ export default class Chat { const id = window.crypto.randomUUID() const time = new Date().toLocaleString() const type = 'text' - this.添加元素({ id, name, text, time, type }) - this.存储消息({ id, name, text, time, type }) - this.send({ id, name, text, time, type }) + const data = { id, name, text, time, type } + this.添加元素(data) + this.存储消息(data) + this.send(data) } 收到消息(data) { console.log('收到消息', data)