[Vuejs]-Vue router handle urls incorrectly in hash mode

0๐Ÿ‘

Itโ€™s a little hacky, but this should work:

Before the VueRouter instantiation, add:

if (!window.location.pathname.endsWith('test/')) {
  window.location.replace(
    `${window.location.href}`.replace(
      window.location.pathname, 
      `${window.location.pathname}`.replace(
        '/test', 
        '/test/')
      )
  )
}

-1๐Ÿ‘

GO to your routes.js and change this

const router = new VueRouter({
  routes: []

to this

const router = new VueRouter({
  mode: 'history',
routes:[]
})

Rebuild your project and re-upload

Vue reference: https://router.vuejs.org/guide/essentials/history-mode.html#example-server-configurations

Leave a comment