vue-router mode使用问题

为什么vue-router将mode从hash变成history之后,index.html加载了,引用的资源也全部正确,可就是页面显示不出来?

mode = hash  OK
const router = new VueRouter({
    routes,
    mode: 'hash',
    strict: process.env.NODE_ENV !== 'production'
})

mode = history NG
const router = new VueRouter({
    routes,
    mode: 'history ',
    strict: process.env.NODE_ENV !== 'production'
})

加载的资源都是一样的.就想去掉url中的那个#;求大神们帮帮忙!!!

clipboard.png

阅读 8.8k
2 个回答

用 history 模式时,还需要后台配置支持,参考文档

mode: 'history ',

请把history后面的空格删除

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题