在 Angular 6 中导入 bootstrap 的正确方法是什么。在以前的版本中我是这样做的并且它工作正常。
angular-cli.json( Angular 5)
"styles": [
"styles.scss"
],
"scripts": [
"../node_modules/jquery/dist/jquery.slim.min.js",
"../node_modules/popper.js/dist/umd/popper.min.js",
"../node_modules/bootstrap/dist/js/bootstrap.min.js"
],
angular.json( Angular 6)
"styles": [
"src/styles.css"
],
"scripts": [
"../node_modules/jquery/dist/jquery.slim.min.js",
"../node_modules/popper.js/dist/umd/popper.min.js",
"../node_modules/bootstrap/dist/js/bootstrap.min.js"
]
获取错误:
Error: ENOENT: no such file or directory, open '/Users/pacozevallos/myApp/node_modules/jquery/dist/jquery.slim.min.js'
最佳答案
此配置应该有效,因为正如您在 angular.json
文件中看到的那样,有属性 "root": "",
用于导入文件,因此请遵循以下代码
"styles": [
"src/styles.scss",
"node_modules/bootstrap/dist/css/bootstrap.min.css"
],
"scripts": [
"node_modules/jquery/dist/jquery.slim.min.js",
"node_modules/popper.js/dist/umd/popper.min.js",
"node_modules/bootstrap/dist/js/bootstrap.min.js"
]
关于angular - 在 Angular 6 中导入 Bootstrap angular.json 错误 : ENOENT: no such file or directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50280575/