如何从Angular项目中删除Bootstrap?

时间:2019-05-15 08:58:58

标签: angular angular-bootstrap mdbootstrap

我正在尝试在Angular项目中使用Material Design Bootstrap(MDB)。但是,当我使用角度引导程序组件时,似乎标准的引导程序会干扰样式。

enter image description here

从我的有角项目中完全删除引导的最佳方法是什么,以便仅通过有角的引导来设置组件的样式?

修改

angular.json

"styles": [
              "node_modules/@fortawesome/fontawesome-free/scss/fontawesome.scss",
              "node_modules/@fortawesome/fontawesome-free/scss/solid.scss",
              "node_modules/@fortawesome/fontawesome-free/scss/regular.scss",
              "node_modules/@fortawesome/fontawesome-free/scss/brands.scss",
              "node_modules/angular-bootstrap-md/scss/mdb-free.scss",
              "src/styles.scss"
            ],

package.json

"dependencies": {
    "@angular/animations": "~7.2.0",
    "@angular/common": "~7.2.0",
    "@angular/compiler": "~7.2.0",
    "@angular/core": "~7.2.0",
    "@angular/forms": "~7.2.0",
    "@angular/platform-browser": "~7.2.0",
    "@angular/platform-browser-dynamic": "~7.2.0",
    "@angular/router": "~7.2.0",
    "@fortawesome/fontawesome-free": "^5.8.2",
    "@types/chart.js": "^2.7.52",
    "angular-bootstrap-md": "^7.5.2",
    "atom": "^1.1.0",
    "chart.js": "^2.5.0",
    "core-js": "^2.5.4",
    "hammerjs": "^2.0.8",
    "jquery": "^3.4.1",
    "rxjs": "~6.3.3",
    "terminal": "^0.1.4",
    "tslib": "^1.9.0",
    "zone.js": "~0.8.26"
  },

3 个答案:

答案 0 :(得分:2)

第一:如下所示,从您的package.json删除引导程序依赖项:

"dependencies": {
    "@angular/animations": "^6.0.0",
    "@angular/common": "^6.0.0",
    "@angular/compiler": "^6.0.0",
    "@angular/core": "^6.0.0",
    "@angular/forms": "^6.0.0",
    "@angular/http": "^6.0.0",
    "@angular/platform-browser": "^6.0.0",
    "@angular/platform-browser-dynamic": "^6.0.0",
    "@angular/router": "^6.0.0",
    "bootstrap": "^3.3.1",   <-------REMOVE THIS
    "core-js": "^2.5.4",
    "rxjs": "6.0.0",
    "zone.js": "^0.8.26"
  },

第二:如果您将引导网址放置在如下所示的样式部分下,则从angular.json中删除引导网址。

"styles": [
    "src/styles.css",
    "node_modules/bootstrap/dist/css/bootstrap.min.css" <--- REMOVE THIS
],

第三:检查并删除styles.css中明确导入的所有引导引用或远程或本地的任何其他文件,如下所示

@import '~bootstrap/dist/css/bootstrap.min.css';

答案 1 :(得分:0)

npm uninstall bootstrap --no-save

还删除您在angular.json中添加的引用,该引用的样式指向bootstrap.min.css

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

答案 2 :(得分:0)

如果你想了解 angular 的原理,或者你是 angular/前端开发的初学者,请按照答案 1,因为第一次手动操作对未来很有帮助,

如果您不是初学者并想节省时间,请粘贴 npm uninstall bootstrap --no-save

我的答案适用于所有 Angular 开发者