目前,我正试图在我的角5项目上实现 navbar元素,它需要三个JS库: Bootstrap 4、jQuery和PopperJS。
它完美无缺地工作在(即没有错误发生)添加到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>然而,, I想做一个实验,将那些三个JS库添加到.angular-cli.json中(而不是在src/index.html上使用CDN ),所以我做了以下工作:
在.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"
],注意:在将这三个脚本添加到.angular-cli.json之前,我已经使用npm安装了Bootstrap 4、jQuery和PopperJS包。
运行它时,控制台上有一个错误(Chrome工具)
Uncaught SyntaxError: Unexpected token export scripts.bundle.js:2302单击它带来的错误消息时
export default Popper;我有点搞不懂到底发生了什么,问题的真正原因是什么?如何修复此错误?
发布于 2018-03-02 10:40:50
npm install --save bootstrap jquery popper.js现在你可以启动你的应用程序了
https://stackoverflow.com/questions/48633945
复制相似问题