api接口要写绝对路径
router.js
// ...
export default new Router({
mode: 'history',
// ...
})
vue.config.js
module.exports = {
publicPath: '/',
// ...
}
服务器配置
这段配置应该放到API的代理的后面,避免覆盖了接口
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>
网友评论