vue.js - 如何使用 nginx 使 vue 项目中的 css 和 js 文件在生产中工作
问题描述
我的 Vue 项目是我在 Ubuntu 18.04 中的路径 vue
/var/www/html/vue/{ project here }
问题是我的 css 路径是/css
指/var/www/html/css
如何在 vue 项目中设置我的 css 在文件夹中参考这里是我的 nginx 设置
server {
listen 80 default_server;
listen [::]:80 default_server;
listen 443 ssl;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
location /vue {
// I try to make root path but It's not workking error 500 when I uncomment #root
#root /var/www/html/vue;
try_files $uri $uri/ /vue/index.html;
}
}
解决方案
您可以使用当前配置尝试以下操作:
location /css {
alias /var/www/html/css;
}
推荐阅读
- algorithm - 从嘈杂的数据中寻找线条
- hadoop - 为什么即使我在集群上添加节点,我的 Hadoop MapReduce 也没有运行得更快?
- go - 解组 XML:根据属性值使用不同的目标类型
- python - pygame显示自动调整大小
- javascript - 在我进行第二次提交后,每当我尝试获取登录页面或注册页面时,我都会收到 404 错误
- django - 如何总结 django 选择中的金额
- django - 如何在 django for chatterbot 的视图中向端点发出 POST 请求?
- swift - SwiftUI 帧大小
- java - 如何使用数字格式类格式化货币
- javascript - 如何使用javascript将postgres sql查询中的值分配给前端的字段