[Vuejs]-Add or removing a class to a element in a child component

0๐Ÿ‘

โœ…

If all you want to do is to toggle the class on the elements, I suggest:

In ChildOne add a selectedItem to data and set it with @click handler.

In ChildTwo add a @click hanlder that will emit click event to the ChildOne compontent.

You can see a working example forked from your CodeSandbox here

I have added font-weight: bold to the .selected class to make it visible.

Leave a comment