vue-material/src/components/mdInputContainer/mdInput.vue

46 lines
993 B
Vue
Raw Normal View History

2016-08-01 05:45:40 +00:00
<template>
<input
class="md-input"
:type="type"
:value="value"
2016-08-01 05:45:40 +00:00
:disabled="disabled"
2016-08-02 05:35:33 +00:00
:required="required"
:placeholder="placeholder"
2016-09-19 03:45:48 +00:00
:maxlength="maxlength"
2016-08-01 05:45:40 +00:00
@focus="onFocus"
@blur="onBlur"
@input="onInput"
@keydown.up="onInput"
@keydown.down="onInput">
2016-08-01 05:45:40 +00:00
</template>
<script>
import common from './common';
import getClosestVueParent from '../../core/utils/getClosestVueParent';
2016-08-02 05:05:32 +00:00
2016-08-01 05:45:40 +00:00
export default {
mixins: [common],
2016-08-01 05:45:40 +00:00
props: {
type: {
type: String,
default: 'text'
2016-08-01 05:45:40 +00:00
}
},
2016-08-31 22:20:23 +00:00
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();
2016-08-01 05:45:40 +00:00
}
};
</script>