Vue.js – How to remove hashbang #! from url?

In Vue 3, you’d want to use createWebHistory for the history option.

import { createRouter, createWebHashHistory } from 'vue-router'

const router = createRouter({
  history: createWebHashHistory(),
  // ...
})

In Vue 2, you’d want to set mode to 'history'.

const router = new VueRouter({
  mode: 'history',
  // ...
})

Make sure your server is configured to handle these links, though.
https://router.vuejs.org/guide/essentials/history-mode.html

Leave a Comment