我在使用某些ng-bootstrap下拉组件时遇到问题,因为依赖于jquery 3x而后者无法找到popper.js
在我的控制台中查看此内容
未捕获错误:Bootstrap下拉列表需要Popper.js
我该如何解决这个问题?
使用npm安装jquery显示对不在npm注册表中的popper.js的依赖
└──UNMETPEER DEPENDENCY popper.js@^1.11.0
以下是package.json
中的依赖项
"dependencies": {
"@angular/animations": "^4.2.4",
"@angular/common": "^4.2.4",
"@angular/compiler": "^4.2.4",
"@angular/core": "^4.2.4",
"@angular/forms": "^4.2.4",
"@angular/http": "^4.2.4",
"@angular/platform-browser": "^4.2.4",
"@angular/platform-browser-dynamic": "^4.2.4",
"@angular/router": "^4.2.4",
"@ng-bootstrap/ng-bootstrap": "^1.0.0-beta.1",
"bootstrap": "^4.0.0-beta",
"core-js": "^2.4.1",
"font-awesome": "^4.7.0",
"jquery": "^3.2.0",
"rxjs": "^5.4.2",
"zone.js": "^0.8.14"
},

由于
答案 0 :(得分:15)
现在可以从npm安装Popper.js:
npm install popper.js --save
答案 1 :(得分:-1)
也许您dependencies
应如下所示。
"dependencies": {
"@angular/animations": "^4.2.4",
"@angular/common": "^4.2.4",
"@angular/compiler": "^4.2.4",
"@angular/core": "^4.2.4",
"@angular/forms": "^4.2.4",
"@angular/http": "^4.2.4",
"@angular/platform-browser": "^4.2.4",
"@angular/platform-browser-dynamic": "^4.2.4",
"@angular/router": "^4.2.4",
"@ng-bootstrap/ng-bootstrap": "^1.0.0-beta.1",
"@bootstrap": "^4.0.0-beta",
"@core-js": "^2.4.1",
"@font-awesome": "^4.7.0",
"@jquery": "^3.2.0",
"@rxjs": "^5.4.2",
"@zone.js": "^0.8.14"
},
希望我会工作
答案 2 :(得分:-2)
在bootstrap.min.js:6 Uncaught Error: Bootstrap dropdown require Popper.js
找到答案看起来popper.js不在npm注册表中,但是它是一个cdn到它,在我的应用程序下面添加index.html解决了下拉列表问题
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>