mirror of
https://github.com/Hopiu/vue-material.git
synced 2026-05-01 03:54:47 +00:00
51 lines
1.1 KiB
Vue
51 lines
1.1 KiB
Vue
<template>
|
|
<input
|
|
class="md-input"
|
|
:type="type"
|
|
:name="name"
|
|
:value="value"
|
|
:disabled="disabled"
|
|
:required="required"
|
|
:placeholder="placeholder"
|
|
:maxlength="maxlength"
|
|
:readonly="readonly"
|
|
@focus="onFocus"
|
|
@blur="onBlur"
|
|
@input="onInput"
|
|
@keydown.up="onInput"
|
|
@keydown.down="onInput">
|
|
</template>
|
|
|
|
<script>
|
|
import common from './common';
|
|
import getClosestVueParent from '../../core/utils/getClosestVueParent';
|
|
|
|
export default {
|
|
name: 'md-input',
|
|
props: {
|
|
type: {
|
|
type: String,
|
|
default: 'text'
|
|
}
|
|
},
|
|
mixins: [common],
|
|
mounted() {
|
|
this.$nextTick(() => {
|
|
this.parentContainer = getClosestVueParent(this.$parent, 'md-input-container');
|
|
|
|
if (!this.parentContainer) {
|
|
this.$destroy();
|
|
|
|
throw new Error('You should wrap the md-input in a md-input-container');
|
|
}
|
|
|
|
this.parentContainer.inputInstance = this;
|
|
this.setParentDisabled();
|
|
this.setParentRequired();
|
|
this.setParentPlaceholder();
|
|
this.handleMaxLength();
|
|
this.updateValues();
|
|
});
|
|
}
|
|
};
|
|
</script>
|