vue去除路径中的 #, 访问页面出现404情况处理

Vue-router 中有hash模式和history模式,vue的路由默认是hash模式,hash 模式和 history 模式都属于浏览器自身的特性

vue 路由配置
const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})
Nginx 配置 解决刷新页面出现404问题
server {
    listen 80;
    server_name localhost;

     location / {
        root /opt/dist;  #默认访问目录
        index index.html index.htm;  #默认访问文件
        try_files $uri $uri/ /index.html;   #目录不存在则执行index.htm
    }
   
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容