0👍
If I understand the problem correctly, the problem is how you’re using v-model on your NewIngredientInput component. It should bind to a single model, but you’re binding to multiple models (amount, unit_measure, name). Here is the simplified solution:
Change your NewIngredientInput
in newrecipe
page like this:
<NewIngredientInput
:value="row"
:showRemoveButton="index > 0"
@removeRow="removeRow(index)"
/>
And:
<template>
<!-- Your existing template code -->
</template>
<script>
export default {
props: {
showRemoveButton: Boolean,
value: { type: Object, required: true },
},
data() {
return { ingredient: { ...this.value } };
},
watch: {
ingredient: {
handler() { this.$emit('update', this.ingredient); },
deep: true
},
value: {
handler(newValue) { this.ingredient = { ...newValue }; },
deep: true
}
},
methods: {
removeRow() { this.$emit("removeRow"); },
},
};
</script>
Hope this helps!
- [Vuejs]-Vite removes format import "import foo from "./assets/foo.svg?component"
- [Vuejs]-Laraval Breeze: page or props is not defined in Vue component
Source:stackexchange.com