-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Closed
Description
#4827 as a refrence that some lifecycle hooks DO have the event
available while not for others.
export default {
props:['hasErrors'],
components: {
'FormErrors': require('./Errors.vue')
},
data() {
return {
input: ''
}
},
mounted () { // get the hidden inputs value
if (this.$el.type == 'hidden') {
this.input = this.$el.value
}
},
watch: { // send data to the central storage to be picked up by the parent
input(val, oldVal) {
storage.data.userInfo[event.target.name] = val;
}
},
}
- error
Cannot read property 'target' of undefined
without mounted()
https://cl.ly/3V3p3U2L2I3j/Screen%20Recording%202017-02-01%20at%2007.59%20PM.gif
with
https://cl.ly/3H3p3j3H3n2J/Screen%20Recording%202017-02-01%20at%2008.01%20PM.gif
fiddle
https://jsfiddle.net/svz0hb8j/2/
now if we replaced watch()
with updated()
the error is gone
updated() {
storage.data.userInfo[event.target.name] = this.input;
},
don't know why this happens specially that both pretty much does the same thing. https://vuejs.org/v2/api/#updated
Metadata
Metadata
Assignees
Labels
No labels