我正在使用 nodejs 和框架 Express 开发应用程序。我想在本地将 Bootstrap 添加到我的项目中。我将其添加到我的索引中 <head>
<script language="javascript" src="../node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css"/>
我发现我必须将此代码添加到我的 app.js
app.use(express.static(__dirname + '../node_modules/bootstrap/dist'));
但它也不起作用。 (我记住了 Bootstrap 的路径并使用’../modules …‘)
原文由 Diego Izquierdo Dussan 发布,翻译遵循 CC BY-SA 4.0 许可协议
你应该在你的 html 文件中引用你的样式表。
安装助推器:
服务器.js
索引.html
此文件应位于 yourProject/views/: