【问题标题】:Bootstrap framework not included in the angular-cliangular-cli 中不包含引导框架
【发布时间】:2017-12-02 17:34:40
【问题描述】:

我已经通过 npm 将 bootstrap 框架安装到 angular2 项目中,它显示在 node-modules 文件夹中。但是,angular-cli 文件没有 boostrap 脚本和 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"
      }
    }
  ],  

我手动尝试在 angular-cli 文件中添加引导位置 css,js 文件并重新启动,但它显示构建错误。还有其他解决方案可以解决此问题吗?

【问题讨论】:

    标签: twitter-bootstrap angular npm angular-cli


    【解决方案1】:

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

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

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

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

    【讨论】:

      【解决方案2】:

      【讨论】:

      • @DeborahK,我只想说我真的很喜欢你的 angular-cli 教程。我发现它真的很有帮助:)
      • 非常感谢。很高兴听到。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-01-11
      • 2017-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-19
      相关资源
      最近更新 更多