我刚刚创建了一个全新的angular-cli项目,
然后运行npm install bootstrap@4.0.0-beta jquery popper.js --save
并更改了.angular-cli.json的相关部分,如下所示
"styles": [
"../node_modules/bootstrap/dist/css/bootstrap.css"
],
"scripts": [
"../node_modules/jquery/dist/jquery.js",
"../node_modules/popper.js/dist/popper.js",
"../node_modules/bootstrap/dist/js/bootstrap.js"
],
但是收到下面的错误
10:2287 Uncaught SyntaxError: Unexpected token export
at eval (<anonymous>)
at webpackJsonp.../../../../script-loader/addScript.js.module.exports (addScript.js:9)
at Object.../../../../script-loader/index.js!../../../../popper.js/dist/popper.js (popper.js?4b43:1)
at __webpack_require__ (bootstrap 4403042439558687cdd6:54)
at Object.2 (scripts.bundle.js:66)
at __webpack_require__ (bootstrap 4403042439558687cdd6:54)
at webpackJsonpCallback (bootstrap 4403042439558687cdd6:25)
at scripts.bundle.js:1
任何想法如何解决?
我有同样的问题。我的解决方案不是导入dist文件夹(./node_modules/popper.js/dist/popper.js),而是导入umd文件夹(./node_modules/popper.js/dist/ umd /popper.js)。获取js文件的迷你版还是普通版都没关系。