Having trouble accessing data within beforeRouteLeave as everything appears to be undefined
Check out the code snippet below:
<template>
...
</template>
<style lang="scss">
...
</style>
<script>
export default {
name: 'blog-new',
data() {
return {
isBodyChanged: false,
isPublished: false,
isTitleChanged: false,
}
},
created() {
...
},
beforeRouteLeave: (to, from, next) => {
console.log(this.isBodyChanged) //<--undefined
if (this.isBodyChanged) {
return next(false)
} else {
return next()
}
}
}
</script>