P
P
pegas2018-01-29 04:43:21
Vue.js
pegas, 2018-01-29 04:43:21

Where does the update:foo event come from?

I read the following in the documentary:
The following will be converted to:
<comp :foo.sync="bar"></comp>

<comp :foo="bar" @update:foo="val => bar = val"></comp>

In order for the child component to update the value of foo, it must explicitly emit an event, instead of changing the input data parameter: I don’t understand what update:foo is ?? is this a special event in Vue that is called when the input parameter changes? changing the value of the parent? And why is this some strange event with a colon ":"?
this.$emit('update:foo', newValue)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Khokhlov, 2018-01-29
@1PeGaS

This is the name of the event, you can either updateBaz or helloWorld to call it.
As for the colon, it's kind of like a namespace. Vue in this case generates the name of the event itself.
According to the documentation
will be converted to
Etc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question