Button click and call method in another component?

Good day everyone, hope you’re doing well. Just wondering as I’m going through Vue.js tutorials online and is this even possible? I want to call method1 in Component2 from the button click in Component1. How would I access that method in another file? Thanks so much for any tips and help, much appreciated.

Component1.vue

<template>
    <div>
        <button @click="method1"/>Ask me</button>
    </div>
</template>

Component2.vue

function method1() {
    console.log('method1 called')
}

If the button is a child of component2, you can emit the event up.

If the components are siblings/quite far apart, then state management is usually the way to go.

1 Like

Perfect, thank you I’ll start there. Much appreciated