I have a parent vue component consisting of a list of items when clicked on an item a edit part child component becomes visible, on the mounted method of the child the parameters are set for edit however when clicking a different item the mounted method on the child is of course not called again, leaving the same state visible how can i reset the child?, the content of the child is sent using props, parent roughly
<div v-for="user in users" :key="user.id" @click=editUser(user)>{{user.name}}
</div>
<EditUser props="editedUser" edit=true v-if=editingUser
method: editUser(user){
this.editingUser=true
this.editedUser.name=user.name;
}
and the child roughly:
mounted:function(){
this.name=editedUser.name;
}
<input type="text" v-model="name"
EditUser
component. In that case there is no reactivity and the child component won't respond to the update on the parent. If that's not the problem, you probably don't setname
on update of theeditedUser
props.mounted
won't be called on props updates; so, you will need to define a watcher for this. Either way: post executable code please. – FK82props="editUser"
if it does anything, is only passing the actual string "editUser" certainly not a object. – skribev-bind
in ` v-bind:title="post.title"` it goes without saying the the shorthand forv-bind
is simply the colon by itself. – skribe