You've already forked pure-component
修复 提示条属性修改BUG;
This commit is contained in:
@@ -258,7 +258,7 @@
|
||||
<p class="component-description">提供美观的下拉选择功能,支持选项分组、自定义样式和响应式设计。</p>
|
||||
|
||||
<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">
|
||||
<button class="btn" onclick="changeSelectOptions()">更改选项</button>
|
||||
<button class="btn" onclick="toggleSelectDisabled()">切换禁用状态</button>
|
||||
|
34
index.js
34
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
|
||||
}
|
||||
}
|
||||
// 初始化
|
||||
|
Reference in New Issue
Block a user