繁体   English   中英

Bootstrap框架未包含在angular-cli中

[英]Bootstrap framework not included in the angular-cli

我已经通过npm安装了bootstrap框架到angular2项目,它显示在node-modules文件夹中。但是,angular-cli文件没有boosts脚本以及css。

"apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": [
        "assets",
        "favicon.ico"
      ],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.app.json",
      "testTsconfig": "tsconfig.spec.json",
      "prefix": "app",
      "styles": [
        "styles.css"
      ],
      "scripts": [],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
  ],  

我手动尝试将bootstrap位置css,js文件添加到angular-cli文件中,然后重新启动,但显示生成错误。是否有其他解决方案可解决此问题?

此处的Angular CLI文档中有说明: https : //github.com/angular/angular-cli/wiki/stories-include-bootstrap

您需要在styles数组中添加css文件,如下所示:

"styles": ["styles.css", "../node_modules/bootstrap/dist/css/bootstrap.css"]

如果您需要bootstrap js文件,则可以如下添加它:

"scripts": ["../node_modules/bootstrap/dist/js/bootstrap.min.js"]

暂无
暂无

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

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