From 6a244555d6e92b053a802df3a75af9c4dfe8a768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A7=89?= Date: Sat, 21 Oct 2023 05:50:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E8=AF=9D=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/chat.js | 18 ++++++++++++++++++ src/weigets.js | 8 +++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/chat.js b/src/chat.js index 1b59cf1..27282b6 100644 --- a/src/chat.js +++ b/src/chat.js @@ -95,9 +95,27 @@ export default class Chat { } 添加元素(data) { this.ul.appendChild(ListItem({ + style: { + display: 'flex', + justifyContent: 'space-between', + alignItems: 'center', + margin: '1rem', + padding: '.5rem 1rem', + boxSizing: 'border-box', + boxShadow: '0 0 1rem #eee', + maxWidth: '24rem', + borderRadius: '1rem', + }, children: [ Span({ textContent: `${data.name} ${data.time} ${data.text}` }), Button({ + style: { + boxSizing: 'border-box', + boxShadow: '0 0 1rem #eee', + borderRadius: '1rem', + fontSize: '12px', + color: '#555' + }, textContent: '删除', onclick: event => { event.target.parentNode.remove() diff --git a/src/weigets.js b/src/weigets.js index 810eb7d..2fb01fe 100644 --- a/src/weigets.js +++ b/src/weigets.js @@ -28,7 +28,13 @@ export function Span(options) { } export function Button(options) { - return createElement(options, 'button') + return createElement({ + ...options, + style: { + cursor: 'pointer', + ...options.style + } + }, 'button') } export function Input(options) {