vue3---hash和history打包部署区别

92 阅读1分钟

接上回创建完成项目,这次是部署一下

history模式

这个模式就很简单,直接上代码,就是要定位到文件所在位置吗

路由配置 image.png

vite.config.ts配置 image.png 然后就是打包,我的是放在了html下了

 location  /dist {
            root   html/;
            index  index.html;
            try_files $uri $uri/ /dist/index.html; 
       }

image.png 这样就可以访问了

image.png

hash模式

其实只需要把路由配置那改为hash模式,再把vite.config.ts的base改为“./”