Skip to content

Instantly share code, notes, and snippets.

@sashadev-sky
Last active April 29, 2022 22:39
Show Gist options
  • Save sashadev-sky/a6cb5fc8ed1b781a0c2ec04efc546825 to your computer and use it in GitHub Desktop.
Save sashadev-sky/a6cb5fc8ed1b781a0c2ec04efc546825 to your computer and use it in GitHub Desktop.
Using beforeRouteEnter with Vue Router
<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