当前位置 : 主页 > 网页制作 > Bootstarp >

如何导入bootstrap 3.3.7模块 – 用于angular2组件

来源:互联网 收集:自由互联 发布时间:2021-06-12
我在导入bootstrap 3.3.7模块时遇到问题并使用它: 在package.json中:我有bootstrap 3.3.7作为依赖: { "name": "plan", "version": "0.0.0", "license": "MIT", "angular-cli": {}, "scripts": { "start": "ng serve", "lint": "
我在导入bootstrap 3.3.7模块时遇到问题并使用它:

在package.json中:我有bootstrap 3.3.7作为依赖:

{
  "name": "plan",
  "version": "0.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
      "start": "ng serve",
      "lint": "tslint \"src/**/*.ts\"",
      "test": "ng test",
      "pree2e": "webdriver-manager update",
      "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
      "@angular/common": "~2.1.0",
      "@angular/compiler": "~2.1.0",
      "@angular/core": "~2.1.0",
      "@angular/forms": "~2.1.0",
      "@angular/http": "~2.1.0",
      "@angular/platform-browser": "~2.1.0",
      "@angular/platform-browser-dynamic": "~2.1.0",
      "@angular/router": "~3.1.0",
      "angular2-text-mask": "^1.0.1",
      "bootstrap": "^3.3.7",
      "core-js": "^2.4.1",
      "font-awesome": "^4.7.0",
      "jquery": "^3.1.1",
      "ng2-bootstrap": "^1.1.16",
      "rxjs": "5.0.0-beta.12",
      "tether": "^1.3.7",
      "ts-helpers": "^1.1.1",
      "zone.js": "^0.6.23"
  },
  "devDependencies": {
      "@types/jasmine": "^2.2.30",
      "@types/node": "^6.0.42",
      "angular-cli": "1.0.0-beta.19-3",
      "codelyzer": "1.0.0-beta.1",
      "jasmine-core": "2.4.1",
      "jasmine-spec-reporter": "2.5.0",
      "karma": "1.2.0",
      "karma-chrome-launcher": "^2.0.0",
      "karma-cli": "^1.0.1",
      "karma-jasmine": "^1.0.2",
      "karma-remap-istanbul": "^0.2.1",
      "protractor": "4.0.9",
      "ts-node": "1.2.1",
      "tslint": "3.13.0",
      "typescript": "~2.0.3",
      "webdriver-manager": "10.2.5"
  }
}

在app.modules.ts中,我在尝试导入模块时出现以下错误:

错误:找不到模块../../../node_modules/bootstrap/dist/js/bootstrap
在第16行第27行

enter image description here

我已经在SO中找到了一些问题,但它没有帮助

Angular2 webpack: how to import bootstrap css

根据 https://angular.io/docs/ts/latest/guide/webpack.html#!#loaders

在你的webpack.config.js中你应该

teach it to process such files into JavaScript with loaders

loaders: [
  {
    test: /\.ts$/
    loaders: 'ts'
  },
  {
    test: /\.css$/
    loaders: 'style!css'
  }
]

你是这样导入的:

import 'uiframework/dist/uiframework.css';
网友评论