What are component events?
A custom event thrown by a component, taking the custom event name and event data, is written as follows:
$emit(' custom event name ', data passed to parent) // Example this.$emit('pageChange',1)Copy the code
< pageChange="change"/> methods:{change(){//}}Copy the code
What is the significance of appearing?
Used by child components to pass data to parent components. In VUE, the data transfer is one-way and the child component cannot change the data of the parent component.
concept
- Throw event: A child component raises an event that it cannot handle and tells the parent to handle it
- Event parameters: Parameters passed to the parent when an event is thrown by a child component
- Registration event: the parent declares that it does something for the child when something happens