我正在免费使用 OpenShift 来制作我的学期论文。我的问题是,在我的根文件夹中,我有文件:rankAplus.html、todo.js 和 dashboard.css。当我在文件 rankAplus HTML 中调用 todo.js 和 dashboard.css 时,出现此错误(未找到 404 - 浏览器错误)。当我在浏览器中查看我的元素仪表板时,文件类型已从 text/css 更改为 text/html。我的 JavaScript 文件也发生了同样的事情。这些文件是同一个文件夹。我需要做什么?有人知道如何解决这个问题吗?
我正在使用 Node JS 在 openshift 上创建服务器。 我正在使用 AngularJS 和 Bootstrap 等引用资料。
我在服务器 openshift 的文件夹结构:
../ repo /
. . . rankAplus.html
. . . todo.js
. . .仪表板.css
.
回调时 rankAplus 的 Server.js 路由:
function showRank(req,res)
{
res.sendfile('rankAplus.html');
}
app.get('/showRank',showRank);
在 rankAplus.html 标题上,我以这种方式调用 todo.js 和 dashboard.css
<script type="text/javascript" src="todo.js"/>
<link href="dashboard.css" type="text/css" rel="stylesheet">
我已经尝试过:
<script type="text/javascript" src="../todo.js"/>
<link href="../dashboard.css" type="text/css" rel="stylesheet">
和...
<script type="text/javascript" src="/todo.js"/>
<link href="/dashboard.css" type="text/css" rel="stylesheet">
但是,没有任何效果。
有人吗?
最佳答案
尝试把完整的 URI 放在
<link href="http://localhost/repo/dashboard.css" type="text/css" rel="stylesheet">
路径区分大小写
Dashboard.css 与基于 linux 和 unix 的系统上的 dashboard.css 不同。
关于javascript - CSS 和 Javascript 文件未加载到我的根文件夹中的 HTML 文件中 - Openshift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29755052/