Join Michael Sullivan for an in-depth discussion in this video Handling events in components, part of Learning Vue.js.
- [Narrator] Now we're gonna take a quick look…at how to handle events that are raised in components.…If we take a look at the methods…in our asteroid grid component,…you might notice that most of them make calculations…but without altering any data.…But in the remove method, we are actually altering…the asteroids prop by removing an element from the array.…And this is something we wanna be very careful with,…especially in more complicated applications.…If I open up the Vue dev tools,…when I click remove, you can see…that under props in my asteroid component,…I now have nine elements in the array…instead of the 10 that I started with.…
And if I go up to the Root and look…at asteroids there, I see the same thing.…But this won't always be the case.…This is the result of the fact…that arrays are passed down to components…by reference and not by value,…so when I edit or mutate this prop,…I'm actually editing the array in the Root instance…because they're one and the same.…This is discouraged in Vue but if I look in the Console,…
- Adding Vue to a webpage
- Thinking declaratively with data binding
- Methods and event handling
- Adding dynamic style and class attributes
- Using CSS transitions and animations
- Using Vue components
- Vue CLI
Skill Level Intermediate
Web Programming Foundationswith Morten Rand-Hendriksen58m 44s Beginner
What you should know1m 29s
1. The Simplest Form
2. Essential Directives, Options, and Tools
3. Enhancing User Interfaces
4. Vue Components
Next steps2m 32s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.