修复 提示条属性修改BUG;

This commit is contained in:
袁涛
2025-08-13 14:03:29 +08:00
parent 9017753f56
commit 961841f4bd
2 changed files with 22 additions and 14 deletions

View File

@@ -258,7 +258,7 @@
<p class="component-description">提供美观的下拉选择功能,支持选项分组、自定义样式和响应式设计。</p> <p class="component-description">提供美观的下拉选择功能,支持选项分组、自定义样式和响应式设计。</p>
<div class="component-demo"> <div class="component-demo">
<ui-select id="demoSelect" list="选项一,选项二,选项三" placeholder="请选择..."></ui-select> <ui-select id="demoSelect" list="选项一,选项二,选项三" value="0,1,2" placeholder="请选择..."></ui-select>
<div class="btn-group"> <div class="btn-group">
<button class="btn" onclick="changeSelectOptions()">更改选项</button> <button class="btn" onclick="changeSelectOptions()">更改选项</button>
<button class="btn" onclick="toggleSelectDisabled()">切换禁用状态</button> <button class="btn" onclick="toggleSelectDisabled()">切换禁用状态</button>

View File

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