From the course: Vue.js 2 Essential Training

Unlock the full course today

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

Using props

Using props

From the course: Vue.js 2 Essential Training

Start my 1-month free trial

Using props

- [Instructor] In order to make my component a little bit more useful, I need to be able to pass along the price of each individual item. So that's what I'm going to do, and it's pretty easy. Let's go ahead and open this up right here and scroll down to where we're passing along this price. And what I need to do here is pass along a prop. So a prop is almost exactly like an HTML attribute, so what I can do here is just say I want to pass along something called value. And then, this is going to get the item price. So remember as we're going through these loop of elements the price is in this variable called item right here. And that's when I'm passing along, just passing along the price. Now this can either be a simple property like this, or it can be a v-bind directive, like this, or you could just use the colon, or the shortcut. The difference would be if you wanted to use an expression here as opposed to just a simple value. So, this will be okay. But if we wanted to use a formula…

Contents