javascript - CSS 和 JS 在 localhost 上工作,但不在 Heroku Webserver 上
问题描述
伙计们,我一直在 Web 平台上工作,但在部署到 heroku 服务器时遇到了一些问题。我的 CSS 和 JS 文件无法加载,尽管这些文件已上传到 heroku。
我正在使用 PHP7 和 Bootstrap 4.0。我已经验证了 CSS 和 JS 链接的路径。我实际上使用 php 包含将我的 head.php 链接到我的主文件 (index.php)。这是代码:
<!-- Bootstrap CSS First Try with the "relative" path used on heroku-->
<link rel="stylesheet" href="vendor/twbs/bootstrap/dist/css/bootstrap.min.css">
<!-- General CSS -->
<link rel="stylesheet" href="assets/css/main_style.css">
<!-- Fav Icon -->
<link rel="icon" type="image/png" sizes="32x32" href="assets/imgs/favicon-32x32.png">
<!-- Bootstrap CSS Second Try with the "absolute" path used on heroku-->`enter code here`
<link rel="stylesheet" href="https://whispering-waters.herokuapp.com/vendor/twbs/bootstrap/dist/css/bootstrap.min.css">
<!-- General CSS -->
<link rel="stylesheet" href="https://whispering-waters.herokuapp.com/assets/css/main_style.css">
<!-- Fav Icon -->
<link rel="icon" type="image/png" sizes="32x32" href="https://whispering-waters.herokuapp.com/assets/imgs/favicon-32x32.png">
<!-- Bootstrap CSS Third Try with CDN-->
<link rel="stylesheet" href="<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<!-- General CSS -->
<link rel="stylesheet" href="https://whispering-waters-50467.herokuapp.com/assets/css/main_style.css">
<!-- Fav Icon -->
<link rel="icon" type="image/png" sizes="32x32" href="https://whispering-waters-50467.herokuapp.com/assets/imgs/favicon-32x32.png">
我原以为这会修复 Heroku 上的 CSS 和 JS 加载问题。我接受任何建议。提前致谢
解决方案
我想到了。问题是作曲家包管理。我修复了项目作曲家的依赖关系,它开始工作了。我意识到 NodeJs npm 和其他包管理器也会出现这个问题。如果有人面临同样的问题,值得尝试验证您的包依赖关系。
我衷心感谢您的支持。
推荐阅读
- python - 树莓派中的乘客计数错误
- asp.net - web.config 中的多租户 httpCookie.domain
- r - 根据 Slider 范围过滤 R Shiny Data Frame 并在数据表中显示结果
- mongodb - 在 $geoNear 阶段的查询中使用 let 变量
- sequelize.js - 为什么我不能在 sequelize-cli 中添加新列?
- reactjs - 通过反应应用程序将 blob 上传到 azure blob 存储
- webdriver - WebdriverIO,IE11窗口启动,但终端错误:由于没有这样的窗口,请求失败,当前焦点窗口已关闭
- github - 如何在 github 中向用户隐藏源代码选项卡?
- javascript - 代码进入javascript中的无限循环
- c# - Xamarin.Android 绑定 Java.Lang.NoClassDefFoundError:“解析失败:Landroidx/viewbinding/ViewBinding;”