From 14dddbe8f565e3382e6b6ea63916eb877d5b5287 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A7=89?= Date: Sat, 21 Oct 2023 05:09:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/chat.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/chat.js b/src/chat.js index e62d096..1b59cf1 100644 --- a/src/chat.js +++ b/src/chat.js @@ -81,7 +81,7 @@ export default class Chat { const item = ListItem({ classList: [type], children: [ - Span({ innerText: `${name} ${time} ${text}` }) + Span({ textContent: `${name} ${time} ${text}` }) ] }) this.ul.appendChild(item) @@ -96,7 +96,14 @@ export default class Chat { 添加元素(data) { this.ul.appendChild(ListItem({ children: [ - Span({ innerText: `${data.name} ${data.time} ${data.text}` }) + Span({ textContent: `${data.name} ${data.time} ${data.text}` }), + Button({ + textContent: '删除', + onclick: event => { + event.target.parentNode.remove() + del(data.id, this.store) + } + }) ] })) }