1👍
✅
I managed to make it work, here’s my code:
child-component
<template>
<b-form-group :label="label">
<no-ssr>
<vue-tags-input
:value="value"
v-model="tag"
placeholder="Add Tag"
:tags="tags"
@tags-changed="updateValue"/>
</no-ssr>
</b-form-group>
</template>
<script>
export default {
name: 'BaseInputTag',
props: {
label: { type: String, required: true },
value: { type: [String, Number, Array] },
tags: { type: [Array, String] },
validations: { type: Object, required: true }
},
data() {
return {
tag: ''
}
},
methods: {
updateValue(newTags) {
this.$emit('updateTags', newTags);
}
}
}
</script>
and to receive the changes to parent component:
<BaseInputTag :tags="interests" @updateTags="interests = $event" label="Interests"/>
<script>
export default {
name: 'InsiderForm',
data() {
return {
tag: '',
interests: []
};
}
}
</script>
2👍
You’re almost there!
Parent component:
<BaseInputTag v-model="tag" :tags="interests" @input="doStuffWithChildValue" label="Interests"/>
<script>
export default {
name: 'InsiderForm',
data() {
return {
tag: '',
interests: []
};
},
methods: {
doStuffWithChildValue (value) {
console.log('Got value from child', value)
}
}
}
</script>
Source:stackexchange.com