I have a vue component to input user address that I need to use twice on same page.
Below my parent containing the two components:
<h3>My Address</h3>
<adress :user="user" ref="userAddress"></adress>
<h3>Adress to delivery</h3>
<adress :user="user" ref="deliveryAddress"></adress>
<button type="submit" class="btn btn-primary pull-right" @click="ConfirmAdress()">Confirm</button>
Here is the vue configurations:
<script>
import AddressComponent from '../components/Address'
export default {
name: 'Adress',
computed: {
user () {
return this.$store.state.user
}
},
components: {
'adress': AddressComponent
}
}
</script>
I send the current user adress to te components so when the component is loaded the fields are filled with current information.
Here is my "Adress" component simplified
<template>
<div>
<div class="form-row">
<div class="form-group col-md-7">
<label for="inputAddress">Adress</label>
<input type="text" class="form-control" id="inputAddress" placeholder="Street, Aveneu" v-model="painelistaToLoad.addressName">
</div>
</div>
</div>
</template>
<script>
export default {
props: ['user']
}
</script>
The goal is to get the values of the filled fields in the two components in the parent. The problem is that when the user changes any input field in the "userAdress" component, the "deliveryAdress" component is updated automatically with the same information. This is my first step.
user
. – Mat J