0

When I go to http://localhost:8080/ It redirects to http://localhost:8080/#/

Why it added "#" ?

import Vue from 'vue'
import App from './App.vue'    
import VueRouter from 'vue-router'
import List from './components/list'
import PostForm from './components/postform'

Vue.config.productionTip = false
Vue.use(VueRouter)             

const routes = [               
  { path: '/', component: List, name: 'root' },
  { path: '/posts/new', component: PostForm }
]     

const router = new VueRouter({ 
  routes
})  

new Vue({
  router,
  render: h => h(App),         
}).$mount('#app')
1

1 Answer 1

3

By default VueRouter uses hash mode.

You can change the mode to history if you want:

const router = new Router({
  mode: 'history',
})

Probably the main reason for doing this is that, if you use history mode you need to have a special setup for your web server to handle the urls properly. When using hash bangs it works out of the box.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.