Skip to content
This repository has been archived by the owner on Apr 30, 2020. It is now read-only.

登陆后刷新页面会显示"404 page not found" #27

Open
tongxiaofeng opened this issue Jul 26, 2017 · 7 comments
Open

登陆后刷新页面会显示"404 page not found" #27

tongxiaofeng opened this issue Jul 26, 2017 · 7 comments
Labels

Comments

@tongxiaofeng
Copy link

问题如标题。

@miaolz123
Copy link
Owner

请问你使用的是二进制版本吗?另外操作系统是什么类型的呢?

@tongxiaofeng
Copy link
Author

是用的二进制版本。windows和mac我都试了,同样都存在这个问题。

@tongxiaofeng
Copy link
Author

screen shot 2017-07-26 at 23 47 45

@miaolz123
Copy link
Owner

因为前端是由 react-router 实现的模拟路由跳转,实际上只有一个页面而已,你如果需要刷新的话可以点击页面左上角的 Reload 按钮,不要直接浏览器刷新。

当然,这个确实让人很迷惑,接下来会重构前端,改掉这个设计~

@miaolz123 miaolz123 added the bug label Jul 27, 2017
@tongxiaofeng
Copy link
Author

我用过vue-rotuer, 是不会出现这种情况的。 我发个链接你参考下。
https://router.vuejs.org/zh-cn/essentials/history-mode.html

HTML5 History 模式

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

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

const router = new VueRouter({
mode: 'history',
routes: [...]
})
当你使用 history 模式时,URL 就像正常的 url,例如 http://yoursite.com/user/id,也好看!

不过这种模式要玩好,还需要后台配置支持。因为我们的应用是个单页客户端应用,如果后台没有正确的配置,当用户在浏览器直接访问 http://oursite.com/user/id 就会返回 404,这就不好看了。

所以呢,你要在服务端增加一个覆盖所有情况的候选资源:如果 URL 匹配不到任何静态资源,则应该返回同一个 index.html 页面,这个页面就是你 app 依赖的页面。

@tongxiaofeng
Copy link
Author

应该是后台的rotuer加一个通配符就好了?

@miaolz123
Copy link
Owner

不错的建议,我试试哈~

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants