Skip to content
Advertisement

How to target and erase a multiplicated component in Vue

I need to target and erase a component that I duplicated using v-for. I’m creating a multiple stopWatch app. At this time I’m able to erase only the last component I duplicated but I want to be able to erase any of the components targeted Here is my component “Counter”:

JavaScript

and there is the App.vue where I want to duplicate or erase my Counter component:

JavaScript

Advertisement

Answer

You can convert count to array then push/filter to add/remove counter:

JavaScript
JavaScript
JavaScript
Advertisement