I'm programming from Vue.js and I'm trying to pass a message to the main App.vue from a component called "SignIn.vue" while using router.
In App.vue:
<template>
<div id="nav">
<router-link to="/signin" @do-login="doLogin">Sign in</router-link>
</div>
</template>
<script>
export default {
data(){
return {
loggedIn:false
}
},
methods:
{
doLogin()
{
alert("Logging you in");
}
}
};
</script>
In SignIn.vue:
<template>
<div class="signin">
<h1>Sign in</h1>
Username: <input type="text" />
Password: <input type="password" />
<button @click="logIn">Go</button>
</div>
</template>
<script>
export default {
methods:{
logIn()
{
this.$emit("do-login");
}
}
};
</script>
However, App.vue is not "hearing" the do-login
event emitted from SignIn.vue. How can I pass messages like this while using router?