vue-material/src/components/mdInputContainer/mdInput.vue
2016-11-14 03:33:04 -02:00

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>