Chrome Extension

Add class to an element condition based in Vuejs

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

<script>
    export default {
        data: function() {
            return {
                index: 0
            }
        }
    }
</script>
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool

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?
0 Comments
Join Devsheet Ask a Question