URL路由上面为什么会有 # 号?可以去它掉吗?

来源:4-2 UI框架快速完成登录业务的样式开发(学会用轮子)

Amormo

2020-06-21 23:28:43

http://img.mukewang.com/climg/5eef7c9f098c7bdb02500061.jpg

写回答

1回答

Brian

2020-06-23

vue-router 默认 hash 模式 —— 使用 URL 的 hash 来模拟一个完整的 URL,于是当 URL 改变时,页面不会重新加载。

如果不想要很丑的 hash,我们可以用路由的 history 模式,这种模式充分利用 history.pushState API 来完成 URL 跳转而无须重新加载页面。

参考:https://router.vuejs.org/zh/guide/essentials/history-mode.html


0

0 学习 · 1842 问题

查看课程