mirror of
https://github.com/Hopiu/vue-material.git
synced 2026-05-24 23:03:45 +00:00
45 lines
993 B
Vue
45 lines
993 B
Vue
<template>
|
|
<input
|
|
class="md-input"
|
|
:type="type"
|
|
:value="value"
|
|
:disabled="disabled"
|
|
:required="required"
|
|
:placeholder="placeholder"
|
|
:maxlength="maxlength"
|
|
@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 {
|
|
mixins: [common],
|
|
props: {
|
|
type: {
|
|
type: String,
|
|
default: 'text'
|
|
}
|
|
},
|
|
mounted() {
|
|
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.setParentDisabled();
|
|
this.setParentRequired();
|
|
this.setParentPlaceholder();
|
|
this.setParentValue();
|
|
this.handleMaxLength();
|
|
}
|
|
};
|
|
</script>
|