Nuxt.js: History navigation not working

Created on 17 Mar 2019  路  5Comments  路  Source: nuxt/nuxt.js

Version

v2.4.0

Reproduction link

https://github.com/begueradj/bug-nuxt-hashbang-history

Steps to reproduce

Call this method on click buttons to scroll down and up the same page:

methods: {                                                                                                                                     
    moveToAnchor(hashbang) {                                                                                                                     
      this.$router.push(`#${hashbang}`)                                                                                                          
      this.$vuetify.goTo(`#${hashbang}`)                                                                                                         
      console.log(this.$route.hash)      // this gives me the right thing                                                                                                        
    }                                                                                                                                            
  }   

What is expected ?

Navigating back and forward the browser history should work

What is actually happening?

Clicking on the browser's back or forward buttons does not move the page anywhere

This bug report is available on Nuxt community (#c8847)
bug-report

All 5 comments

@begueradj Does it work in pure vue + vue-router? :thinking:

I use only Nuxt.js but I will try it in Vue.js by the end of the day, thank you for the feedback.

@begueradj Just to make sure it's not a vue-router bug :relaxed:

@manniL You were right, there is this same issue with Vue.js (vue-router). I will try to understand what is going on before reporting a bug to Vue.js team. Somehow I think router.push() expects only routes, not anchors within the same route; but then it is mysterious that console.log(this.$route.hash) outputs the anchors in question. Thank you very much for the feedback, handsome and smart boy.

@begueradj Glad I could help :relaxed:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vadimsg picture vadimsg  路  3Comments

mikekidder picture mikekidder  路  3Comments

lazycrazy picture lazycrazy  路  3Comments

mattdharmon picture mattdharmon  路  3Comments

bimohxh picture bimohxh  路  3Comments