mode改成history后,页面首页访问正常,其他页面刷新报404错误
export default new Router({
mode : 'history',
routes: [
{
path: '/',
name: 'index',
component: index
},
]
})
解决:在网站根目录添加.htaccess文件
文件内容
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
这样刷新就可以啦