要在Angular 6中使用Bootstrap 4.1.3的下拉菜单,您需要遵循以下步骤:
安装Bootstrap和jQuery:
npm install bootstrap@4.1.3 jquery --save
在.angular-cli.json文件中添加样式和脚本:
"styles": [
"styles.css",
"../node_modules/bootstrap/dist/css/bootstrap.min.css"
]
"scripts": [
"../node_modules/jquery/dist/jquery.min.js",
"../node_modules/bootstrap/dist/js/bootstrap.min.js"
]
重启应用程序:
在组件中使用下拉菜单:
注意:确保使用正确的Bootstrap类和属性来定义下拉菜单。
编译和运行应用程序:
ng serve
您应该能够在Angular 6应用程序中看到工作的Bootstrap 4.1.3下拉菜单。
请注意,如果您使用的是Angular CLI版本7或更高版本,.angular-cli.json
文件已被重命名为angular.json
,请相应地进行更改。