[Vuejs]-Vue-router change mode at runtime

1👍

Changing the mode doesn’t do anything while the mode is only used in the constructor of VueRouter. With the mode VueRouter executes the following code (https://github.com/vuejs/vue-router/blob/dev/src/index.js):

switch (mode) {
  case 'history':
    this.history = new HTML5History(this, options.base)
    break
  case 'hash':
    this.history = new HashHistory(this, options.base, this.fallback)
    break
  case 'abstract':
    this.history = new AbstractHistory(this, options.base)
    break
  default:
    if (process.env.NODE_ENV !== 'production') {
      assert(false, `invalid mode: ${mode}`)
    }
}

But basically it’s better to recreate your VueRouter

-1👍

So, why don’t you initiate it using mode: "hash"?

Leave a comment