Im very new to Vue.js. I’m trying to build a simple app that totals a list of items. But it also, should have the option to ‘disable’ the individual items so that their value would not contribute to the total. (UPDATE: the button should toggle the disabled state)
Visually, the disabled items would simply be greyed-out, (i dont want their amounts showing zero)
I was imagining perhaps, targeting the parent item with a disabled attribute (when the btn is clicked). And then….a check would be made for the existence of this attribute, when the totalling is done (and any item without the attribute (class?) would be skipped)
But I have no idea how this would work in Vue World. Anyone willing to help out please? Or even point me in the right direction?
HTML
<div id="app">
<div id="item1">{{ item1.amt }} <button type="button">exclude me</button></div>
<div id="item2">{{ item2.amt }} <button type="button">exclude me</button></div>
<div id="item3">{{ item3.amt }} <button type="button">exclude me</button></div>
<br>
<div id="total">total: {{ item1.amt + item2.amt + item3.amt }}</div>
</div>
JS
var app = new Vue({
el: "#app",
data: {
item1: {
amt: 10
},
item2: {
amt: 20
},
item3: {
amt: 30
}
}
});
https://codepen.io/dagford/pen/oyKXYP?editors=1010
thank you