简体   繁体   English

无法将引导程序添加到 Angular 项目

[英]Not able to add bootstrap to Angular Project

I am trying to add bootstrap to my angular project but I am not able to.我正在尝试将引导程序添加到我的 angular 项目中,但我无法做到。 I am not getting any errors either.我也没有收到任何错误。

I even tried some of the solutions on stackoverflow.我什至在stackoverflow上尝试了一些解决方案。 I am using Angular 7. I have installed bootstrap, jquery and popper.js.我正在使用 Angular 7。我已经安装了引导程序 jquery 和 popper.js。 I have also added them to angular.json.我还将它们添加到 angular.json。

Below is my angular.json下面是我的angular.json

"styles": [
              "src/styles.css",
              "./node_modules/bootstrap/dist/css/bootstrap.min.css"
            ],
            "scripts": [ "./node_modules/jquery/dist/jquery.min.js",
              "../node_modules/popper.js/dist/umd/popper.min.js",
              "./node_modules/bootstrap/dist/js/bootstrap.min.js"],

Following is my import statement in AppModule.ts以下是我在AppModule.ts中的导入语句

import { bootstrap } from 'bootstrap';

I havent included it in the imports array.我还没有将它包含在导入数组中。 Because when I did I got the following error因为当我这样做时,我得到了以下错误

Unexpected value 'undefined' imported by the module 'AppModule'

Any help would be much appreciated.任何帮助将非常感激。

It's not required to import bootstrap in your AppModule.ts file, You can use bootstrap classes without import any module.不需要在AppModule.ts文件中导入引导程序,您可以在不导入任何模块的情况下使用引导程序类。 Because you already imported bootstrap css and js files in your angular.json file因为您已经在angular.json文件中导入了引导程序 css 和 js文件

"./node_modules/jquery/dist/jquery.min.js",
"./node_modules/bootstrap/dist/js/bootstrap.min.js",
"./node_modules/popper.js/dist/umd/popper.min.js"

Maybe you exceeded another dot for popper.js .也许你超过了popper.js的另一个 Check also your node_modules if the paths are correct.如果路径正确,还要检查您的 node_modules。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM