【问题标题】:I have a problem between nodejs express and bootstrap我在 nodejs express 和 bootstrap 之间有问题
【发布时间】:2021-04-01 00:10:44
【问题描述】:

大家好,我尝试将引导程序应用到我的网站 当我只打开 html 文件时,引导文件适用于 html 文件但是当我打开快速服务器时,引导文件不适用于 html 文件

this is an image file of html file

and this is express server i caputured

this is error log

这是错误日志但我认为这很难阅读所以让我添加图像

拒绝应用来自 'http://localhost:3000/vendor/bootstrap/css/bootstrap.min.css' 的样式,因为它的 MIME 类型 ('text/html') 不是受支持的样式表 MIME 类型,并且严格MIME 检查已启用。 localhost/:1 拒绝应用来自 'http://localhost:3000/vendor/fontawesome-free/css/all.min.css' 的样式,因为它的 MIME 类型 ('text/html') 不是受支持的样式表 MIME 类型,并启用严格的 MIME 检查。 localhost/:1 拒绝应用来自 'http://localhost:3000/vendor/simple-line-icons/css/simple-line-icons.css' 的样式,因为它的 MIME 类型('text/html')不是支持样式表 MIME 类型,并启用严格的 MIME 检查。 (index):1 拒绝应用来自 'http://localhost:3000/css/landing-page.min.css?ver=1' 的样式,因为它的 MIME 类型 ('text/html') 不是受支持的样式表 MIME类型,并启用严格的 MIME 检查。 (索引):291 GET http://localhost:3000/vendor/jquery/jquery.js net::ERR_ABORTED 404(未找到) (索引):292 GET http://localhost:3000/vendor/bootstrap/js/bootstrap.bundle.min.js net::ERR_ABORTED 404(未找到) (索引):195 GET http://localhost:3000/img/testimonials-1.jpg 404(未找到) (索引):202 GET http://localhost:3000/img/testimonials-2.jpg 404(未找到) (索引):208 GET http://localhost:3000/img/testimonials-3.jpg 404(未找到) 3(索引):1 GET http://localhost:3000/img/imac-1999636_1920.png 404(未找到) (索引):291 GET http://localhost:3000/vendor/jquery/jquery.js net::ERR_ABORTED 404(未找到) (索引):292 GET http://localhost:3000/vendor/bootstrap/js/bootstrap.bundle.min.js net::ERR_ABORTED 404(未找到)

【问题讨论】:

    标签: javascript html jquery css node.js


    【解决方案1】:

    您很可能没有正确配置 express。

    app.use(express.static(__dirname + "/static"));
    

    404 页面可能会以内容类型 text/html 进行响应。 您的日志显示您的浏览器无法加载图像或 JavaScript 文件。 请查看此官方文档。 https://expressjs.com/en/starter/static-files.html

    【讨论】:

      猜你喜欢
      • 2021-03-17
      • 2015-05-09
      • 2021-04-13
      • 2016-02-10
      • 2013-11-29
      • 1970-01-01
      • 1970-01-01
      • 2022-06-20
      • 2020-11-26
      相关资源
      最近更新 更多