首页 > 其他 > 详细

去掉vue地址栏中分隔#问题

时间:2017-06-30 10:54:26      阅读:253      评论:0      收藏:0      [点我收藏+]
你需要开启HTML5 History 模式
vue-router 默认 hash 模式 —— 使用 URL 的 hash 来模拟一个完整的 URL,于是当 URL 改变时,页面不会重新加载。
如果不想要很丑的 hash,我们可以用路由的 history 模式,这种模式充分利用 history.pushState API 来完成 URL 跳转而无须重新加载页面。
const router = new VueRouter({
mode: ‘history‘,
routes: [...]
})

这种配置需要配合后端服务器的配置,如果你对服务器是nginx
location / {
try_files $uri $uri/ /index.html;
}

去掉vue地址栏中分隔#问题

原文:http://www.cnblogs.com/wyd168/p/7097733.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!