2023年2月8日
vue路由 history模式 nginx配置
vue路由 history模式 nginx配置 – 简书 (jianshu.com)
vue的history模式nginx配置 – 简书 (jianshu.com)
我最终成功的nginx配置是参考第二篇处理的,类似这样的
路由配置
//路由对象
const router = createRouter({
// history: createWebHashHistory(),
history:createWebHistory('/app'),
routes //上面的路由数组
})
配置打包时候,上下文
vite.config.js
export default defineConfig({
base: 'app',
....
})
location /app {
alias /home/zou/www/app;
index index.html index.htm;
try_files $uri $uri/ /app/index.html;
}