Vue-router 在构建生产后不会删除 hashbang

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

我试图删除 hashbang,我通过在 vue-router 的索引文件中添加 mode:'history' 来做到这一点:

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

然后当我在热重载模式下尝试它时它运行良好但是在 运行 npm run build 之后它由于一些奇怪的原因停止了工作。

请帮忙:)

由于答案已在评论中解决,并且 VonC 建议添加一个答案以便对其他人有所帮助,这里是:

因为你正在使用 nginx 运行 文件

设置 nginx 的服务器配置,如 docs

中的示例所示
location / { 
    try_files $uri $uri/ /index.html; 
}