export default {
mounted() {
setTimeout(function() {
this.$emit('onLoad')
}, 4000);
}
} //views/Load.vue
I want to redirect to another page after the page has been accessed for 4 seconds.
<template>
<div id="app">
<transition name="fade" mode="out-in">
<router-view
@onLoad="changeRoute('login')">
</router-view>
</transition>
</div>
</template>
<script>
export default {
name: 'app',
methods: {
changeRoute (routeName) {
this.$router.push({ name: routeName })
}
}
}
</script> //App.vue
The goal is to use '$emit' to send a signal to 'App.vue' and then navigate to the connected page through the router.
All routers are correctly configured.
However, the error "Uncaught TypeError: this.$emit is not a function" is displayed.
How can I resolve this issue?