javascript - CSS 未加载到 node.js 上的 easyrtc 应用程序中

标签 javascript css node.js easyrtc

我的 easyrtc 应用程序中有一些 css 问题,这是我的物理文件结构

  • 元素

    • 登录
      • CSS
        • 样式.css
      • js
        • 脚本.css
      • 登录.html
      • 注销.html
    • Node 模块
    • 静态的
      • server.js
      • package.json

在我定义的 server.js 中,

app.get('/', function(req, res, next) {
 res.redirect('/login');
});

app.get('/login', function(req, res, next) {
 res.sendfile('login.html', {root: './login'});
});

在我的 login.html 中包含以下链接

<link rel="stylesheet" href="css/login.css" media="screen" type="text/css" />

我也试过

<link rel="stylesheet" href="./login/css/login.css" media="screen" type="text/css" />

但是这个 css 文件没有加载到浏览器,我已经检查了元素。但是源代码中有一个空的 css 文件。 我怎样才能解决这个问题? localhost:8080 的根是什么我的网络服务器在端口 8080 上运行 虽然我经历了this nodejs express solution但恐怕我现有的元素可以使用这种解决方案。如果是,我如何添加快速中间件来加载 css? 提前帮忙。愿 FOSS 与您同在。

最佳答案

通常与 easyrtc 一起使用的 server.js(在 server_example 目录中提供)有一个名为 static 的目录,它作为提供服务的静态文件的根目录。例如,如果将名为 xxx.htmlyyy.css 的文件放在静态文件夹中,则可以将 xxx 引用为

  http://yoursite.com/xxx.html

在 xxx.html 中,您可以在链接语句中引用 yyy.css 作为

href="yyy.css"

href="/yyy.css"

不用说,子目录按预期工作。

关于javascript - CSS 未加载到 node.js 上的 easyrtc 应用程序中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27139311/

相关文章:

jquery - 我不想受 css 影响的图像正在受其影响

javascript - 使用 Mongoose 在 JSLint 中抑制 `Expected an identifier and instead saw ' default'(保留字)

javascript - 部署生产 Node.js 服务器

node.js - 我使用异步 waterfall ,为什么回调不是函数?

javascript - 联合接口(interface)类型上不存在属性

javascript - 在 Firefox 扩展中重定向请求(nsiHttpChannel?)

javascript - polymer 2 应用程序 : paper-button has no text

javascript - jQuery 字段验证 - 是否为空,以及正确的值?

CSS 在插入的 div 后缩进段落?

javascript - 如何设置滚动条的默认位置