[Vuejs]-Changing button colors and sending a prop to child component on click with vue.js

0👍

First, ref is not a native HTML attribute so you can not bind it. However, it’s a custom attribute that vue compiles, so you can use as a normal one.

Also the $refs['modelA'] will have the reference for the Vue element, Vue.js wraps the native HTML elements as well.

Finally. you can store the choosen model in the vue data, and pass it as a prop to the child component.

I created a jsfiddle for you.

https://jsfiddle.net/z3qv1dtp/

Also, I recommend you use Vue data to store the button configuration and pass them as props to each button instead of mutating the Vue element directly.

https://jsfiddle.net/z3qv1dtp/1/

Leave a comment