api接口要寫絕對路徑
router.js
// ...
export default new Router({
mode: 'history',
// ...
})
vue.config.js
module.exports = {
publicPath: '/',
// ...
}
服務(wù)器配置
這段配置應(yīng)該放到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>