<!-- Use preprocessors via the lang attribute! e.g. <template lang="pug"> -->
<template>
  <div id="app">
  <div      @click="toggleItem1()" 
            v-bind:class="{'myClass': showMe}">Click me - I toggle</div>

    <div><p></p></div>
  
  <div    @click="toggleItem2()" 
            v-bind:class="{'myClass': showMeArr[0]}">Click me - I don't toggle</div>
  </div>
</template>

<script>
export default {
  data() {
    return {
        showMe: true,
        showMeArr: [true]
    };
  },
  methods: {
        toggleItem1: function(){
          this.showMe = !this.showMe;
        },
        toggleItem2: function(){
          this.showMeArr[0] = !this.showMeArr[0];
        }
  }
};
</script>

<!-- Use preprocessors via the lang attribute! e.g. <style lang="scss"> -->
<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}

.myClass {
  background-color: #aaaaaa;    
}
  
</style>
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.