javascript - 在角度项目上安装引导程序
问题描述
嗨,我的机器上有最新的 angular cli。我试图在 Angular 项目上安装引导程序。这些是我遵循的步骤。
- 新的演示
- npm install bootstrap jquery --save
然后在我复制下面代码的 angular.json 文件中的 vs code 中打开项目。
“样式”:[“styles.css”,“../node_modules/bootstrap/dist/css/bootstrap.css”],“脚本”:[“../node_modules/jquery/dist/jquery.min.js” ,“../node_modules/bootstrap/dist/js/bootstrap.js”]
之后我运行项目 ng serve 我收到了这个错误消息。
Angular Live Development Server 正在监听 localhost:4200,在http://localhost:4200/上打开浏览器** 91% 额外的资产处理脚本-webpack-plugin× 「wdm」: Error: ENOENT: no such file or directory,打开 'D:\Angular\node_modules\jquery\dist\jquery.min.js'
解决方案
Angular 6 及更高版本的 CLI 项目将使用 angular.json
而不是.angular-cli.json
用于构建和项目配置。
每个 CLI 工作区都有项目,每个项目都有目标,每个目标都可以有配置。文档
. {
"projects": {
"my-project-name": {
"projectType": "application",
"architect": {
"build": {
"configurations": {
"production": {},
"demo": {},
"staging": {},
}
},
"serve": {},
"extract-i18n": {},
"test": {},
}
},
"my-project-name-e2e": {}
},
}
在您的 angular.json 中,将文件路径添加到build
目标下的样式和脚本数组中,./
而不是../
Boostrap 4不再支持Glyphicons,您可以使用Font Awesome代替:
执行npm install --save font-awesome
并将文件路径添加到样式数组
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/ng6",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.css","./node_modules/bootstrap/dist/css/bootstrap.min.css"
"./node_modules/font-awesome/css/font-awesome.css"
],
"scripts": ["./node_modules/jquery/dist/jquery.min.js",
"./node_modules/bootstrap/dist/js/bootstrap.min.js"]
},
推荐阅读
- c++ - 自定义数组迭代器的取消引用运算符
- php - 如何从背包 laravel 中的 select2_from_ajax_multiple 中保存多个值
- docker - Jenkins 无法使用 unix 用户/组进行身份验证
- python - 如何使用 python 将 3D 云数据点转换为网格?
- r - 使用 fct_relevel 给出错误:`f` must be a factor (or character vector)
- r - 网页抓取和重塑数据
- javascript - Bootstrap 导航栏切换按钮不起作用
- flutter - Flutter 中 Vector 类的神秘属性
- python - python 属性设置器参数的类型注释应该是什么?
- sqlite - 烧瓶会话cookie