宝塔部署ant-design-pro vue配置

我心飞翔 分类:vue

一、在Vue框架中解决404

vue router mode 默认为hsas,这样的url中会带有#,如果改成mode:'history'就能去掉#号,也可以正常访问,但是再次率先你页面就会出现404

const router = new Router({
mode: 'history'
});

二、修改nginx配置文件

解决页面刷新404问题

location / {
    ……
    try_files $uri $uri/ /index.html;
}

三、解决刷新404问题

location / {
  if ( !-e $request_filename ) {
    rewrite ^/(.*) /index.html last;
    break;
  }
}
宝塔部署ant-design-pro vue配置

参考文档:

https://www.jb51.net/article/261803.htm

回复

我来回复
  • 暂无回复内容