Vue-router doesn't remove hashbang after building for production

ぃ、小莉子 提交于 2019-12-24 07:14:43

问题


I was trying to remove the hashbang and I did it by adding mode:'history' in the index file of vue-router:

export default new Router({
  mode: 'history',
  routes: [
    {
      path: '/',
      name: 'Daksh',
      component: Daksh
    },
    {
      path: '/about',
      name: 'About',
      component: About
    },
    {
      path: '/work',
      name: 'Work',
      component: Work
    }
  ]
})

Then It was working well when I tried it in the hot reload mode but after running npm run build, It stopped working for some weird reason.

Please Help :)


回答1:


As the answer has been solved within the comments and as VonC suggested to add an answer so that it could be helpful for others , here it is:

Sinceyou are using nginx to run the files

Setup the server configuration for nginx as shown in example in the docs

location / { 
    try_files $uri $uri/ /index.html; 
}


来源:https://stackoverflow.com/questions/43999259/vue-router-doesnt-remove-hashbang-after-building-for-production

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!