[Vuejs]-Vue.js: passing class to nested tag in component

1👍

You can directly bind props to html attributes.

In MyButton.vue:

<i class="fa fa-lg" :class="[icon]"></i>

Or you can just pass icon as a string.

<i class="fa fa-lg" :class="icon"></i>

Then, you would have to pass the props to your component caller.

<my-button icon="fa-close"></my-button>

Leave a comment