vue-admin-template刷新的时候会遇到404或空白的问题,这个问题是因为开启了history模式

但是后台的nginx或apache并没有支持,这时把后台nginx或apache加上就可以了
#nginx
location / {
try_files $uri $uri/ /index.html;
}
#apache
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
这样就可以了,这部分内容在官网上也有,
如果后端不支持的话,就只能禁用history模式了,把mode屏蔽了就可以了

当使用vue-admin-template并开启history模式时,刷新页面可能出现404或空白。这通常由于后台服务器如nginx或apache未配置支持。为解决此问题,需更新后台服务器配置,或者若后端不支持,可选择禁用history模式。
2196

被折叠的 条评论
为什么被折叠?



