gpt4 book ai didi

CSS 样式未应用于 View

转载 作者:行者123 更新时间:2023-11-27 23:36:19 26 4
gpt4 key购买 nike

我正在使用 node.js 和 express 创建一个应用程序。我使用哈巴狗作为我的模板引擎。样式表中的样式未应用于 View 。

在我的 header.pug 文件中有

link(rel='stylesheets/style.css', type='text/css', href='/stylesheets/style.css')

样式表位于 public/stylesheets 中。我还在我的 app.js 文件中包含了以下代码。

// serve static files from /public
app.use(express.static(__dirname + '/public'));

app.set('view engine', 'pug');
app.set('views', __dirname + '/views');

当我运行应用程序并期待文档时,我可以在新的点击中打开样式表并查看样式表,但它没有将这些样式应用到 pug 文件?

最佳答案

先删除/

同时改变相对属性

喜欢:

    link(rel='stylesheet', type='text/css', href='stylesheets/style.css')

关于CSS 样式未应用于 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57229044/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com