title: Scroll to anchor on refresh or on manual URL change
body: <p>I implemented the code from <a href="https://stackoverflow.com/a/49328627/1735672">this post</a>, enabling the scroll to anchor while navigating using the router.</p>
  
  <p>But I noticed that on a refresh or manual navigation (by manipulating the URL), the page does not scroll to anchor as expected.</p>
  
  <p>I can add this code to all pages, and it is going to work:</p>
  
  <pre><code>mounted() {
      console.log('Location:', location.hash); //returns '#options'
      console.log('Route:', this.$route.hash); //returns '#options'
  
      if (location.hash)
          this.$nextTick().then(() =&gt; this.$scrollTo(location.hash, 700));
  }
  </code></pre>
  
  <p><strong>Is there any global way to set this code, without having to set the code in every page?</strong></p>
  
  <p>I've tried to set that on the <code>App.vue</code> file, the <code>location.hash</code> prop returns the correct hash, but <code>this.$scrollTo()</code> says that it can't find any object with that ID.</p>