3👍
✅
Processing steps:
- axios api is calling
- component is created
- next() in
beforeRouteEnter
is called. At that time, because component is created, sovm
variable is available.
If you console log in your component
created() {
console.log('Component is created!')
},
beforeRouteEnter(to, from, next) {
setTimeout(() => {
next(vm => {
console.log('next() is called')
})
}, 3000)
},
Then the result will be
Component is created!
next() is called
You should set default value to your data, or add a safety check.
<template>
<main>
<h1>{{ entry? entry.title: '' }}</h1>
</main>
</template>
Source:stackexchange.com