Join Michael Sullivan for an in-depth discussion in this video Using the created lifecycle hook, part of Learning Vue.js.
- In the last video we successfully fetched some data…asynchronously and assigned values…to two properties in our Vue Instance.…But there are some things that I don't like…about this solution.…We just kind of slapped it down here at the bottom…and it's not really obvious at a glance why it's there…and there's no way for us to reuse it if we wanted to.…The first change I am going to make is to add a…method to our Vue Instance and put this code inside it.…Along with the API key and URL.…
(typing)…So in the methods object I'm gonna add fetchApod…which is a function that makes our asynchronous…request to the API.…And this is gonna need to know…about the API key and the URL.…
Once that's done we could just call…vm.fetchApod to get the same result.…That would be fine but now we still have…this dangling code down here that just…sort of looks like an after thought to the main attraction.…But how else can we call this method…as soon as our Vue Instance is created.…The answer is to use something called the hook.…So hook is an interface that can be used to…
- 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.