【发布时间】:2020-11-12 19:24:00
【问题描述】:
这是我的目录
newTab.jade 代码
doctype html
html
head
title New Tab
link(rel = 'stylesheet', type = 'text/css', href = '/public/index.css')
body
p hello world
index.css 代码
p{
background-color: black;
color: white;
}
app.js 代码
const express = require('express');
const app = express();
const port = 3000;
app.locals.pretty = true;
app.listen(port, function(){
console.log("Server Connected port: "+port);
});
app.set('view engine', 'jade');
app.set('views', './views');
app.get('/', function(req, res){
res.render('newTab');
});
jade 文件无法加载 css 文件。 我试过了 href = "/public/index.css" 但它也不起作用。
【问题讨论】:
-
检查网络标签。你能观察到对 CSS 文件的请求吗?
-
我不明白“网络标签”的含义
-
我上传的代码就是我的代码。
-
在浏览器的开发人员工具中 (F12),有一个网络选项卡记录页面发出的请求。打开该选项卡,然后刷新页面,看看您的页面发出了什么样的请求。
-
该错误通常意味着找不到css文件。您的快速配置不包括任何静态文件配置。更多信息请参考this。
标签: javascript html css express pug