【问题标题】:I cannot link css file to html when rendering with inert使用惰性渲染时,我无法将 css 文件链接到 html
【发布时间】:2019-01-12 06:52:48
【问题描述】:

我将 css 文件链接到 html(newPersonel.html) 如下:

<head><link rel="stylesheet" href="newPersonel.css"></head>

我的路由定义如下:

const start = async function() {

    await server.register(Inert);

    //*** Add route */
    server.route({
        method: 'GET',
        path: '/new',
        handler: {
            file: 'newPersonel.html'
        }
    });


    try {
        await server.start();
    }

    catch (err) {
        console.log(err);
        process.exit(1);
    }
    console.log(`Server running at: ${server.info.uri}`);

};
start();

它正在渲染 html 页面,但没有获取到 css 文件的链接并尝试将其作为 GET 方法。

GET http://localhost:5000/newPersonel.css net::ERR_ABORTED 404(未找到)

我在这里错过了什么?

【问题讨论】:

  • 请检查位于给定 url 中的 css 是否尝试在新选项卡中使用 url 如果未加载则在 css 放置位置发出问题
  • 感谢您的回答@Sethuraman。但它在里面。也许您在指出其他一些我无法理解的事情。 html页面即将到来,但未应用css。 html 和 css 文件都在同一个目录中。

标签: html css mongodb


【解决方案1】:

我跳过添加 app.use(express.static(__dirname + "/public")); 现在解决了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-22
    • 2018-03-18
    • 1970-01-01
    • 2020-11-30
    相关资源
    最近更新 更多