2016-11-30 61 views
0

我最近使用ng-cli啓動了一個angular2 web應用程序。我試圖將Twitter-bootstrap(我使用npm安裝)添加到我的index.html文件中。由於某些原因,即使路徑正確,它似乎也找不到引導程序。我錯過了什麼嗎? ng-cli是否在其他地方移動bootstrap?angular2 ng-cli:無法將twitter-bootstrap添加到index.html

我的代碼:

<link rel="stylesheet" href="./../node_modules/bootstrap/dist/css/bootstrap.min.css" type="text/stylesheet"> 

回答

1

角CLI不工作,你正在做的方式。它添加如下的第三方庫。

  1. 附加使用NPM

    NPM安裝引導@未來

  2. 添加在應用程式腳本和樣式文件的[0] .scripts中和應用[0] .styles的angular-特性安裝庫cli.json。像

    apps": [ 
        { 
         "root": "src", 
         "outDir": "dist", 
         ...... 
    
         "styles": [ 
         "../node_modules/bootstrap/dist/css/bootstrap.css", 
         "styles.css" 
         ], 
         "scripts": [ 
         "../node_modules/bootstrap/dist/js/bootstrap.js", 
         ], 
         "environments": { 
         "source": "environments/environment.ts", 
         "dev": "environments/environment.ts", 
         "prod": "environments/environment.prod.ts" 
         } 
        } 
        ], 
    

加入這樣了。它會將所有文件添加到index.html中