美文网首页
vue Router history 配置

vue Router history 配置

作者: Aooiu | 来源:发表于2019-05-10 14:48 被阅读0次

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>

相关文章

网友评论

      本文标题:vue Router history 配置

      本文链接:https://www.haomeiwen.com/subject/gmdaoqtx.html