Last active
April 29, 2022 22:39
-
-
Save sashadev-sky/a6cb5fc8ed1b781a0c2ec04efc546825 to your computer and use it in GitHub Desktop.
Using beforeRouteEnter with Vue Router
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div>Hi I am the about page {{ info }}</div> | |
</template> | |
<script> | |
export default { | |
props: { | |
info: String | |
}, | |
beforeRouteEnter(to, from, next) { | |
next(vm => { | |
if (vm.info) next() | |
else next({ name: "home" }) | |
}) | |
}, | |
mounted() { | |
console.log("mounted called") | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment