title: Vue - How to access data inside beforeRouteLeave - In Component Guard
body: <p>Trying to access data inside beforeRouteLeave but everything is <code>undefined</code></p>
  
  <p>Code below</p>
  
  <pre><code>&lt;template&gt;
    ...
  &lt;/template&gt;
  
  &lt;style lang="scss"&gt;
    ...
  &lt;/style&gt;
  
  &lt;script&gt;
  
    export default {
      name: 'blog-new',
      data() {
        return {
          isBodyChanged: false,
          isPublished: false,
          isTitleChanged: false,
        }
      },
      created() {
        ...
      },
      beforeRouteLeave: (to, from, next) =&gt; {
        console.log(this.isBodyChanged) //&lt;--undefined
        if (this.isBodyChanged) {
          return next(false)
        } else {
          return next()
        }
      }
    }
  &lt;/script&gt;
  </code></pre>