feat: input disable prop

This commit is contained in:
07akioni 2019-06-17 19:58:09 +08:00
parent 8f9ecc211f
commit 3525e0f1df
3 changed files with 34 additions and 5 deletions

View File

@ -36,6 +36,19 @@
placeholder="abcdd" placeholder="abcdd"
/></textarea> /></textarea>
<hr> <hr>
<h2>disabled</h2>
<n-input
v-model="value"
disabled
placeholder="abcdd"
/>
<br>
<textarea rows="5"><n-input
v-model="value"
disabled
placeholder="abcdd"
/></textarea>
<hr>
</div> </div>
</template> </template>

View File

@ -2,12 +2,16 @@
<div <div
v-if="type==='textarea'" v-if="type==='textarea'"
class="n-input" class="n-input"
:class="{
'is-disabled': disabled
}"
> >
<textarea <textarea
class="inner-textarea" class="n-input__textarea"
rows="3" rows="3"
:placeholder="placeholder" :placeholder="placeholder"
:value="value" :value="value"
:disabled="disabled"
@input="handleInput" @input="handleInput"
/> />
</div> </div>
@ -17,9 +21,10 @@
> >
<input <input
type="text" type="text"
class="inner-input" class="n-input__input"
:placeholder="placeholder" :placeholder="placeholder"
:value="value" :value="value"
:disabled="disabled"
@input="handleInput" @input="handleInput"
> >
</div> </div>
@ -44,6 +49,10 @@ export default {
value: { value: {
type: String, type: String,
default: '' default: ''
},
disabled: {
type: Boolean,
default: false
} }
}, },
methods: { methods: {

View File

@ -2,11 +2,18 @@
@import './theme/default.scss'; @import './theme/default.scss';
@include b(input) { @include b(input) {
.inner-input { &.is-disabled {
.n-input__input, .n-input__textarea {
background-color: #6F778D;
}
}
.n-input__input {
box-sizing: border-box; box-sizing: border-box;
border: none; border: none;
border-radius: 8px; border-radius: 8px;
padding: 10px 20px; padding: 0 20px;
height: 36px;
line-height: 36px;
outline: none; outline: none;
background-color: #6F768B; background-color: #6F768B;
font-size: 14px; font-size: 14px;
@ -20,7 +27,7 @@
opacity: 1; opacity: 1;
} }
} }
.inner-textarea { .n-input__textarea {
box-sizing: border-box; box-sizing: border-box;
border: none; border: none;
border-radius: 8px; border-radius: 8px;