Javascript 如何在角度应用程序中集成引导CSS
我有两个类似的非常小的示例Angular应用程序,它们集成了引导CSS。一个有效,一个我自己创造的无效。目前还不清楚区别是什么,以及为什么在我的案例中不起作用 我的步骤如下:Javascript 如何在角度应用程序中集成引导CSS,javascript,css,angular,Javascript,Css,Angular,我有两个类似的非常小的示例Angular应用程序,它们集成了引导CSS。一个有效,一个我自己创造的无效。目前还不清楚区别是什么,以及为什么在我的案例中不起作用 我的步骤如下: npm install bootstrap --save 这将更新package.json,然后更新index.html并添加 <link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css"> 与工作应
npm install bootstrap --save
这将更新package.json
,然后更新index.html
并添加
<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css">
与工作应用程序完全相同,但在我使用ng new-app
创建的示例应用程序中,它不工作
chrome中的网络选项卡显示404。基本上找不到URL
在Angular应用程序中集成引导CSS的正确/完整方法是什么?因为您使用的是Angular CLI: 更新.angular-cli.json文件以包含引导样式:
"styles": [
"../node_modules/bootstrap/dist/css/bootstrap.min.css",
],
无需将其包含在索引中。html您似乎正在使用angular&angular cli 如果是这种情况,那么您实际上可以将bootstrap.css文件添加到
.angular cli.json
中对应于样式
键的数组中,如下所示
"styles": [
"styles.less",
"../node_modules/bootstrap/dist/css/bootstrap.min.css"
]
另外两种可能性是使用
@import
在main.css文件中导入此bootstrap.css
,或者您可以在mainindex.js
文件中要求此功能。asnwer by@brk将实现此功能,否则您可以始终在index.html中使用CDN