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.

Deleting items and modifiers

Deleting items and modifiers

From the course: Vue.js 2 Essential Training

Start my 1-month free trial

Deleting items and modifiers

- [Instructor] We need to find a way of deleting an item just in case I'm purchasing things and I realize that I don't need this many Bamboo Thermal Ski coats. So I'm going to add a delete button right here. So to do that, I'm going to go into my HTML first, and then find a place where I am listing the items, and I'm going to create a link here, and because it's a link I need to put something in the HREF, and then I need to target the click event. I can use the v-on directive or again use the shortcut which is just an add sign. And in here, what I want to do is call a method that I will be creating called deleteItem and pass along the index. So this index is coming from this loop, as they go through each of the elements. I'm asking Vue.js to generate an index and I'm passing that along to deleteItem. I'll go ahead and put in a minus sign in there. And then we need to add some Bootstrap classes to make it look nice. So badge, badge-danger, and text-white. I think that should be showing…

Contents