0

我正在尝试将我的 CSS 文件与 hbs 链接,但由于某种原因,hbs 没有响应我的 css。
我已将我的 css 文件存储在公用文件夹中,并将其配置为我的 app.js 文件中的静态文件夹。
出于某种原因,它在某些视图中运行良好

这是我的 .hbs 文件::

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="css/pas.css">
</head>
<body>
    fdigu[dip]
</body>
</html>

这是我的 CSS 文件:

body {
    background-color: blue;
  }

这就是我在 app.js 文件中配置公共文件夹的方式:

// HBS Setup
  const path = require("path");
  const hbs = require('hbs');
  const template_path = path.join(__dirname, './templates/views');
  const partials_path = path.join(__dirname, './templates/partials');
  hbs.registerPartials(partials_path);
  app.set("views", template_path);
  app.set("view engine", "hbs");
  app.use(express.static(path.join(__dirname,'public')));

请询问是否需要其他任何东西来调试此问题。

4

0 回答 0