[英]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.