在我的angular10应用程序中,我实现了ng-bootstrap collapse。
component.html
<div class="op-bg-dark-blue op-font-12 darkblue-block-padding" (click)="collapse.toggle()"
[attr.aria-expanded]="!isCollapsed" aria-controls="collapseExample">
<span class="mb-0 op-text-white font-bold">Total Bid Rate</span>
<span class="mb-0 float-right op-text-white font-bold">105,328 <i class="fa fa-angle-right ml-1">
</i></span>
</div>
<div #collapse="ngbCollapse" [(ngbCollapse)]="isCollapsed">
</div>component.ts
isCollapsed = false;但问题是,当我单击div打开callapse时,它会给出一个错误
_r0.toggle is not a function我该如何解决这个问题呢?
发布于 2021-03-19 20:23:50
Hello @FahadSubzwari我在stackblitz尝试过来自ng-bootstrap.github.io的ng-bootstrap collapse example。但是,正如您在问题中演示的那样,我没有发现任何错误。但我发现,除非我将index.html更改为代码below=>,否则该按钮什么也做不了
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.22.0/themes/prism.css" />
</head>
<body>
<div class="container-fluid">
<my-app>loading</my-app>
</div>
</body>
</html>对于collapse来说,这两个stylesheet内部头部是必需的。
所以,你可以查看我的stackblitz演示链接=> Demo of ng-bootstrap in Stackblitz。
https://stackoverflow.com/questions/66707167
复制相似问题