# Nginx 配置文件示例,用于部署 Vue 项目
server {
listen 80;
server_name yourdomain.com; # 替换为你的域名
# 设置根目录为 Vue 项目的 dist 文件夹
root /path/to/your/vue-project/dist;
# 默认首页
index index.html;
# 处理前端路由模式 (history mode)
location / {
try_files $uri $uri/ /index.html;
}
# 可选:配置静态资源缓存
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires max;
add_header Cache-Control "public, no-transform";
}
# 错误页面重定向
error_page 404 /404.html;
location = /404.html {
internal;
}
}
dist 文件夹)。index.html。index.html,从而让前端路由正常工作。上一篇:vue常用组件及ui框架
下一篇:vue @change
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站