Clinton Green Clinton Green - 1 month ago 12
Javascript Question

Vue js - Getting Methods to work in Components

I have a component that passes in data, then I need to change that data from true to false on click. I have created a method called

for that but it's not working, and I am not getting any errors.

Vue.component('moustache', {
name: 'moustache',
props: ['type', 'img'],
template: `<li>
<p><strong>@{{ type }}</strong></p>
<img width="300" height="200" src="/img/image.jpg">
<button class="btn btn-primary" v-bind:class="{ active: isActive }" :data-type="type" @click="toggleClass">Vote</button>
data: function(){
isActive: false
methods: {
isActive: true

new Vue({
el: '#app'


You need to use this so that you can access the component properies:

     this.isActive = !this.isActive;