gpt4 book ai didi

node.js - 在 Express 中包含 Bootstrap Glyphicons

转载 作者:太空宇宙 更新时间:2023-11-03 22:54:01 24 4
gpt4 key购买 nike

我正在尝试在我的 Express 应用程序中使用字形(通过 Bootstrap )。问题是当我提供静态文件时,不包含字形。

这是我的目录(由 grunt 创建):

Build

fonts
glyphicons-halflings.eot
...

js
scripts.js

stylesheets
styles.css

这是我的 app.js 代码:

app.use('/build/', express.static(path.join(__dirname, 'build/js')));
app.use('/build/', express.static(path.join(__dirname, 'build/stylesheets')));
app.use(express.static(path.join(__dirname, 'build/fonts')));

这是来自 chrome 的错误:

users:1 GET http://localhost:3000/fonts/glyphicons-halflings-regular.woff 404 (Not Found) users:1 GET http://localhost:3000/fonts/glyphicons-halflings-regular.ttf 404 (Not Found)

我尝试切换到

app.use('/build/', express.static(path.join(__dirname, 'build/fonts')));

但我很确定 bootstrap 正在寻找 ../fonts,所以目录不可能完全相同。换句话说,bootstrap 需要这样的结构:

js/bootstrap.js
fonts/glyphs

我去哪儿了?

谢谢大家!

最佳答案

只需使用以下内容即可:

app.use('/fonts/', express.static(path.join(__dirname, 'build/fonts')));

关于node.js - 在 Express 中包含 Bootstrap Glyphicons,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29932271/

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