From 961841f4bd0802890e5b552ec41e6a769b2d50c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A2=81=E6=B6=9B?= Date: Wed, 13 Aug 2025 14:03:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E6=9D=A1=E5=B1=9E=E6=80=A7=E4=BF=AE=E6=94=B9BUG=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 +- index.js | 34 +++++++++++++++++++++------------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/index.html b/index.html index bb6c0b7..03d2841 100644 --- a/index.html +++ b/index.html @@ -258,7 +258,7 @@

提供美观的下拉选择功能,支持选项分组、自定义样式和响应式设计。

- +
diff --git a/index.js b/index.js index 3a547b1..f261657 100644 --- a/index.js +++ b/index.js @@ -382,7 +382,6 @@ class UI { // 下拉框 this.Select = class Select extends HTMLElement { // 可用属性 - static observedAttributes = ['placeholder', 'list', 'value', 'current', 'disabled', 'focus'] static get observedAttributes() { return ['placeholder', 'list', 'value', 'current', 'disabled', 'focus'] } @@ -589,7 +588,7 @@ class UI { }) } } - // TODO:加载中 + // 加载中 this.Loading = class Loading extends HTMLElement { static observedAttributes = ['content', 'inline', 'hidden'] constructor() { @@ -1374,10 +1373,12 @@ class UI { }) } } - // TODO:提示条 + // 提示条 this.Tip = class Tip extends HTMLElement { // 可用属性 - static observedAttributes = ['content', 'type', 'hidden', 'timeout'] + static get observedAttributes() { + return ['content', 'type', 'hidden', 'timeout'] + } constructor() { super() // 提示条 @@ -1400,15 +1401,22 @@ class UI { } // 属性变化 attributeChangedCallback(name, oldValue, newValue) { - if (name == 'hidden') { - this[name] = newValue - if (this[name]) { - this.hide() - } - } else if (name == 'timeout') { - this[name] = Number(newValue) - } else if (name == 'type') { - this.Tip.className = this.Tip.part = `tip ${newValue}` + switch (name) { + case 'hidden': + this[name] = newValue + if (this[name]) { + this.hide() + } + break + case 'timeout': + this[name] = Number(newValue) + break + case 'type': + this.Tip.className = this.Tip.part = `tip ${newValue}` + break + case 'content': + this[name] = newValue + break } } // 初始化