From the course: Vue.js 2 for Web Designers

Unlock the full course today

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

Listen for an event with v-on

Listen for an event with v-on - Vue.js Tutorial

From the course: Vue.js 2 for Web Designers

Start my 1-month free trial

Listen for an event with v-on

- [Instructor] In this video we're going to do something a little more complex with our data, which means adding methods and event listeners. Specifically we're going to update the colors data for our view instance when the selected size changes. We need to do a little setup for this first. I need to start with some colors data to update. So I'm going to add a key called colors to my data object, and I'm going to pull that data from the same inventory object. I'm pretty sure this is called all colors. I'm going to type Cmd + P, which'll open up my open a file list here, here's chapter two inventory, and yes, it is called all colors, and there they are. Okay, so this will start me off. Just like with computed properties, which are functions that return some data, now what I need to do here is add a function that can be called from my template on an event listener. The way to do that is to add a methods key to my view instance. These will be functions that I can call elsewhere from…

Contents