From the course: Vue.js 2 Essential Training

Unlock the full course today

Join today to access over 22,700 courses taught by industry experts or purchase this course individually.

Lifecycle hooks

Lifecycle hooks

From the course: Vue.js 2 Essential Training

Start my 1-month free trial

Lifecycle hooks

- [Instructor] We have a pretty nice interface. But just reading everything from a static, sort of, hard coded object is impractical. You would probably want to use something like Ajax or the newer Fetch API to bring in some data. And with Vue JS that's actually pretty easy but a JS calls need to happen at a specific time. So let's got ahead and modify this. And what I'm going to do is just go ahead and actually get rid of all of this right here. Let's go ahead and hide this, so, we don't get some funky stuff happening there. So we're going to delete this. And instead of referring to that variable that we don't have any longer, what I'll do is I'm going to create an object like I had before. And I'll set up the maximum. I'll set it back up to 99. And then I'm going to initialize a variable for my products. Now, it's important that I do this because information is only going to be reactive if it exists when this component gets created. So if I just read the data into a variable using…

Contents