我正在学习Angular,并且Bootstrap和下拉菜单存在问题。
Bootstrap类加载良好,但是下拉菜单不起作用,这就是我对新项目Angular所做的事情:
npm install bootstrap jquery popper --save
当我进行npm审核时,结果是
https://codepen.io/Anduril53/pen/LoPgyz?editors=1010
angular.json中的样式
"styles": [
"src/styles.scss",
"node_modules/bootstrap/dist/css/bootstrap.min.css"
],
答案 0 :(得分:0)
尝试
https://github.com/lichunbin814/angular_bootstarp_dropdown
"styles": [
"src/styles.scss",
"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"
],
答案 1 :(得分:-1)
为什么要使用bootstrap ..您可以使用Angular材质,这是一个很棒的angular框架,它具有许多功能并且易于使用。 stpes: 1-安装包 npm install-保存@ angular / material @ angular / cdk @ angular / animations
2-将角材料集成到您的项目中 ng添加@ angular / material
3-重新启动服务器(ng服务)
4-现在您可以使用角形材料的任何成分。这是链接 https://material.angular.io/components/categories
5-例如,如果要下拉菜单,则需要在app模块中添加select组件的api(一个模块),然后才能在all app中使用它。
使用选择组件: 1-在应用程序模块中添加api 从“ @ angular / material / select”导入{MatSelectModule};
imports : [MatSelectModule]
2-转到项目上的任意组件并添加该组件
嘿