This repository has been archived on 2023-08-30. You can view files and clone it, but cannot push or open issues/pull-requests.
bytedo
/
wcui
Archived
1
0
Fork 0

修复readonly/disabled属性设置

old
宇天 2021-04-26 11:38:54 +08:00
parent 59076f2c54
commit 4f4cac8ddc
6 changed files with 19 additions and 16 deletions

View File

@ -343,8 +343,8 @@ export default class Input {
props = { props = {
value: '', value: '',
placeholder: '', placeholder: '',
maxlength: null, maxlength: 0,
minlength: null, minlength: 0,
clearable: false, clearable: false,
autofocus: false, autofocus: false,
readonly: false, readonly: false,
@ -608,7 +608,7 @@ export default class Input {
break break
case 'value': case 'value':
this.value = val this.value = val || ''
break break
case 'maxlength': case 'maxlength':

View File

@ -170,19 +170,19 @@
} }
// ------- // -------
:host([type='default']) { :host([type='help']) {
color: var(--color-grey-2); color: var(--color-grey-2);
&::after { &::after {
border-color: var(--color-grey-1); border-color: var(--color-grey-1);
} }
} }
:host([type='default']:not([disabled]):hover) { :host([type='help']:not([disabled]):hover) {
color: var(--color-grey-1); color: var(--color-grey-1);
} }
:host([type='default']:not([disabled]):active) { :host([type='help']:not([disabled]):active) {
color: var(--color-grey-3); color: var(--color-grey-3);
} }
:host([type='default']:not([disabled]):focus-within) { :host([type='help']:not([disabled]):focus-within) {
box-shadow: 0 0 0 2px var(--color-grey-a); box-shadow: 0 0 0 2px var(--color-grey-a);
} }
</style> </style>

View File

@ -424,7 +424,7 @@ export default class Number {
if (k === 'readonly') { if (k === 'readonly') {
k = 'readOnly' k = 'readOnly'
} }
this[k] = true this[k] = val !== null
break break
} }
} }

View File

@ -494,7 +494,7 @@ export default class Select {
if (k === 'readonly') { if (k === 'readonly') {
k = 'readOnly' k = 'readOnly'
} }
this[k] = true this[k] = val !== null
break break
} }
} }

View File

@ -189,8 +189,9 @@ export default class Switch {
switch (name) { switch (name) {
case 'checked': case 'checked':
case 'disabled': case 'disabled':
this[name] = true this[name] = val !== null
break break
case 'active-text': case 'active-text':
case 'inactive-text': case 'inactive-text':
console.log('------------->>>') console.log('------------->>>')

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="label"> <div class="label">
<textarea spellcheck="false"></textarea> <textarea spellcheck="false"></textarea>
<div class="input-stat">0/100</div> <div class="input-stat">0/</div>
</div> </div>
</template> </template>
@ -139,8 +139,8 @@ export default class Textarea {
props = { props = {
value: '', value: '',
placeholder: '', placeholder: '',
maxlength: null, maxlength: 0,
minlength: null, minlength: 0,
autofocus: false, autofocus: false,
readonly: false, readonly: false,
disabled: false, disabled: false,
@ -268,17 +268,19 @@ export default class Textarea {
break break
case 'value': case 'value':
this.value = val this.value = val || ''
break break
case 'maxlength': case 'maxlength':
case 'minlength': case 'minlength':
if (val === null) { if (val === null) {
this.__INPUT__.removeAttribute(name) this.__INPUT__.removeAttribute(name)
this.props[name] = 0
} else { } else {
let n = +val let n = +val
if (n > 0) { if (n > 0) {
this.__INPUT__.setAttribute(name, +val) this.__INPUT__.setAttribute(name, n)
this.props[name] = n
} }
} }
break break
@ -293,7 +295,7 @@ export default class Textarea {
if (k === 'readonly') { if (k === 'readonly') {
k = 'readOnly' k = 'readOnly'
} }
this[k] = true this[k] = val !== null
break break
} }
} }