0

I've vue component and in it I wrote a function: when button is clicked likes get + 1 but it never works, I tried to write it inside component like this `@click="this.likes++' but not working, after that I created a method but it also not working. any help?

Vue.component('task-list',{
  template: '<div><button @click="ggg">click me</button>{{ likes }}</div>',
  data(){
    return{
      likes:1
    }
  },
  methods:{
    ggg(){
      this.likes++
    }
  }
});

1 Answer 1

1

Are you sure you are doing this properly? I have created a codesandbox using your code snippet and it works perfectly.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.