Answer the question
In order to leave comments, you need to log in
How to configure an input component from a parent component?
I need an input component from bootstrap 3 that implements validation and error display logic.
I go about it like this:
<template>
<div>
<div class="form-group" v-bind:class="{'has-error': error}">
<input
class="form-control"
v-bind:placeholder="placeholder"
v-model="value"
@change="$emit('value:update', $event.target.value)"
/>
<div class="help-block" v-if="error">
{{error}}
</div>
</div>
</div>
</template>
<script>
export default {
props: {
placeholder: {
type: String,
required: true
},
},
data() {
return {
value: null,
error: null
}
}
}
</script>
Answer the question
In order to leave comments, you need to log in
I have no way to pass the description of the validation procedure from the parent to the component instance
I would like to be able to somehow cancel the transfer of a value that has not passed validation to the top
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question