如何从url中删除hashbang #!
?
我在vue路由器文档( http://vuejs.github.io/vue-router/en/options.html )中找到了禁用#!
的选项,但是这个选项删除了#
,只放入了hashbang
有没有办法拥有干净的url?
示例:
不是:#!/home
但是:/home
谢谢!
发布于 2016-01-06 10:47:44
您实际上只需要将mode
设置为'history'
即可。
const router = new VueRouter({
mode: 'history'
})
不过,请确保您的服务器已配置为可以处理这些链接。https://router.vuejs.org/guide/essentials/history-mode.html
发布于 2016-11-19 10:12:53
对于vue.js 2,请使用以下内容:
const router = new VueRouter({
mode: 'history'
})
发布于 2018-08-09 17:19:55
对于Vuejs 2.5和vue-router 3.0,上面的东西对我来说都不起作用,但在尝试了一下后,似乎可以做到以下几点:
export default new Router({
mode: 'history',
hash: false,
routes: [
...
,
{ path: '*', redirect: '/' }, // catch all use case
],
})
请注意,您还需要添加catch-all路径。
https://stackoverflow.com/questions/34623833
复制相似问题