Vue.js

[Vue.js] Deleting Items and Modifiers

brightlightkim 2022. 5. 11. 08:52
//HTML
<a href="#" @click="deleteItem(index)"
	class="badge badge-danger">-</a>

//JS
methods: {
	deleteItem: function(id) {
    	if(this.cart[id].qty > 1){
        	this.cart[id].qty--;
        } else {
        	this.cart.splice(id, 1);
            //remove JS object
        }
    }
}

//modifiers make Bootstrap menu interesting and fun

 

'Vue.js' 카테고리의 다른 글

[Vue.js] Vue-Cli and other tools  (0) 2022.05.12
[Vue.js] Components based Vue  (0) 2022.05.12
[Vue.js] Adding computed classes  (0) 2022.05.11
[Vue.js] Categorizing lists  (0) 2022.05.11
[Vue.js] Toggling elements with a key  (0) 2022.05.11