<div id="app">
  <div @click="handleDivClick" :style="[styleObj, {fontSize: '30px'}]">
    hello world
  </div>
</div>
var app = new Vue({
  el: "#app",
  data: {
    styleObj: {
      color: "#000"
    }
  },
  methods: {
    handleDivClick: function () {
      this.styleObj.color = this.styleObj.color === "#000" ? "red" : "#000";
    }
  }
});

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/vue/2.7.8/vue.min.js