繁体   English   中英

使用angular-cli时无法加载twitter bootstrap资源

[英]Failing to load twitter Bootstrap resource when using angular-cli

我已经使用Angular CLI构建了我的第一个Angular2应用程序。 我正在尝试使用twitter Bootstrap模块,但找不到它:

Failed to load resource: the server responded with a status of 404 (Not Found) 
http://localhost:4200/node_modules/bootstrap/dist/css/bootstrap.css 

我有一个index.html,其中的以下行

<link href="site.css" rel="stylesheet">

然后,我在./public/site.css中也有一行:

@import 'node_modules/bootstrap/dist/css/bootstrap.css';

Bootstrap模块位于../ node_modules / bootstrap / dist / css / ..,但仍然找不到。 关于我在做什么错有什么想法吗?

angular-cli-builds.js ,您需要添加文件,以便在构建过程中将其复制。

vendorNpmFiles: [
  ...
  'bootstrap/dist/css/bootstrap.css'
]

然后它将在供应商文件夹的浏览器中可用,因此将site.css更改为

@import 'vendor/bootstrap/dist/css/bootstrap.css';

如果不起作用,请在构建后手动检查dist/文件夹,找到文件并更新路径...

更多信息在这里: 3rd party lib安装

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM