[英]Couldn't add Bootstrap 4, jQuery, and PopperJS libraries to .angular-cli.json
Currently i'm trying to implement Bootstrap 4 navbar
element on my Angular 5 project, and it needs three JS libraries, Bootstrap 4, jQuery, and PopperJS. 目前,我正在尝试在Angular 5项目上实现Bootstrap 4 navbar
元素,它需要三个JS库,即Bootstrap 4,jQuery和PopperJS。
It works flawlessly (ie NO ERROR occurred) when I add following to src/index.html
当我在src/index.html
添加以下内容时,它可以完美地工作(即没有错误发生)
<head>
...
...
...
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</head>
However, I wanted to do an experiment by adding those three JS libraries to the .angular-cli.json
(instead of using CDN on src/index.html
), so I did following: 但是,我想做一个实验,将这三个JS库添加到.angular-cli.json
(而不是在src/index.html
上使用CDN),所以我做了以下工作:
On .angular-cli.json
, i add: 在.angular-cli.json
,我添加:
"scripts": [
"../node_modules/jquery/dist/jquery.slim.min.js",
"../node_modules/popper.js/dist/popper.js",
"../node_modules/bootstrap/dist/js/bootstrap.min.js"
],
Note: before adding those three scripts to .angular-cli.json
I already installed Bootstrap 4, jQuery and PopperJS packages using npm
. 注意:在将这三个脚本添加到.angular-cli.json
我已经使用npm
安装了Bootstrap 4,jQuery和PopperJS软件包。
When running it, there is an Error on console (Chrome Dev Tool) 运行它时,控制台上出现错误(Chrome开发工具)
Uncaught SyntaxError: Unexpected token export scripts.bundle.js:2302
When clicking on the error message it brought to this line 当单击错误消息时,它显示到此行
export default Popper;
I'm kinda confused on what's happening and what's the real cause of the problem? 我对正在发生的事情以及问题的真正原因是什么感到困惑? How to fix this error? 如何解决这个错误?
npm install --save bootstrap jquery popper.js
angular-cli.json: angular-cli.json:
"styles": [ "../node_modules/bootstrap/dist/css/bootstrap.min.css", "styles.css" ], "scripts": [ "../node_modules/jquery/dist/jquery.min.js", "../node_modules/popper.js/dist/umd/popper.js", "../node_modules/bootstrap/dist/js/bootstrap.min.js" ],
Now u can launch your app 现在您可以启动您的应用了
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.