要解决Angular 8组件中的Bootstrap下拉按钮不起作用的问题,您可以尝试以下方法:
import { Component, ViewChild, ElementRef, AfterViewInit } from '@angular/core';
@Component({
// 组件配置
})
export class YourComponent implements AfterViewInit {
@ViewChild('dropdownButton') dropdownButton: ElementRef;
ngAfterViewInit() {
// 初始化下拉按钮
$(this.dropdownButton.nativeElement).dropdown();
}
}
npm install bootstrap@latest jquery@latest --save
然后,重新启动您的应用程序。
请注意,上述解决方法假设您已正确安装了Bootstrap和jQuery,并且在项目中引入了相关的样式和脚本。如果您的问题仍然存在,可能还需要检查浏览器的开发者工具中是否有任何错误消息,并确保没有其他代码干扰了Bootstrap下拉按钮的功能。