Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

71
Views
Difference between @click="variable.someFunction" and @click="variable.someFunction()"

I have a question about @click in vue.

If my component looks like this, it sais this is null:

//testcomponent.vue
<template>
<button @click="variable.someFunction">Click me</button>
</template>

<script>
const default_layout = "default";

export default {
    name: "TestComponent",
    data() {
        return {
            variable: {
                value: "test",
                someFunction() {
                    console.log(this)
                }
            }
        }

    }
}
</script>

If I change the button's code to:

<button @click="variable.someFunction()">Click me</button>

It sais this is:

{
    someFunction: ƒ someFunction()
    value: "test"
}

I couldn't find any documentation on this issue, does anyone know why vue supports both definitions, but have different behaviour?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!