vue Router history 配置

2019-05-10  本文已影响0人  Aooiu

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>
上一篇 下一篇

猜你喜欢

热点阅读