码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2017-06-30 11:10:35      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:问题   服务器   try_files   配置   mic   ati   ext   size   ros   

你需要开启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地址栏中分隔#问题

标签:问题   服务器   try_files   配置   mic   ati   ext   size   ros   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!