Chrome Extension

Add class to an element condition based in Vuejs

    <div v-bind:class="{'show_me': index === 0}">
        Hello World

    export default {
        data: function() {
            return {
                index: 0

In Vuejs, if you want to add CSS class to an element, you can use v-bind:class attribute of Vuejs. In the code snippet, we have added class "show_me" based on index value that is defined in data when exporting this Vue component.

Was this helpful?
Never leave your website again in search of code snippets by installing our chrome extension.
Open Code Manager