Vue.js - 如何删除 hashbang #!从网址? [英] Vue.js - How to remove hashbang #! from url?

查看:27
本文介绍了Vue.js - 如何删除 hashbang #!从网址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从url中删除hashbang #!?

How to remove hashbang #! from url?

我在 vue 路由器文档中找到了禁用 hashbang 的选项(http://vuejs.github.io/vue-router/en/options.html ) 但是这个选项删除了 #! 并且只放了 #

I found option to disable hashbang in vue router documentation ( http://vuejs.github.io/vue-router/en/options.html ) but this option removes #! and just put #

有没有办法让网址干净?

Is there any way to have clean url?

示例:

不是:#!/home

但是:/home

谢谢!

推荐答案

您实际上只想将 mode 设置为 'history'.

You'd actually just want to set mode to 'history'.

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

不过,请确保您的服务器配置为处理这些链接.https://router.vuejs.org/guide/essentials/history-mode.html

Make sure your server is configured to handle these links, though. https://router.vuejs.org/guide/essentials/history-mode.html

这篇关于Vue.js - 如何删除 hashbang #!从网址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆