0đź‘Ť
âś…
Hey so it depends of where the component is situated, but generally a button will be on the “internal” component commonly referred to as the child component (as it is placed inside of the “parent” component) in this case you would need to emit upwards and then react to the event in the parent, would look something like this:
//Parent
<template>
<childWithButton @buttonClick="doSomething"/>
</template>
.
.
.
methods: {
doSomething(){
....<
}
}
...
//child ("childWithButton")
<template>
<button @click="$emit('buttonClick')></button>
</template>
Source:stackexchange.com