I have developed a component with the function "logout" as seen in the code snippet below:
// @/component/Painel.vue
<template></template>
<script>
export default {
name: 'panel',
methods: {
logout: function () {
this.$session.destroy()
this.$router.push('/')
}
}
}
</script>
Now, I am looking to utilize the "logout" function defined in Painel.vue within Navbar.vue as shown below:
// @/component/Navbar.vue
<template>
<div class="navbar">
<a @click="logout" class="nav-link m-2 my-2 my-md-0" >Logout</a>
</div>
</template>
<script>
export default {
name: 'navbar'
}
</script>
I have attempted to import the Painel component and call the logout function but have encountered issues.
import Painel from '@/components/authentication/Painel.vue'
...
this.logout()
What is the correct way to achieve this integration between components?