我有一个名为top和bottom的输入参数,正如它们所声明的那样,它是CSS中的top和bottom。当我将组件0中的输入添加到顶部时,CSS样式中不存在0。例如顶部:0px不在此处显示。
<k-sidebar [id]="'testId'"
[attachToBody]="true"
[top]="0"
[bottom]="60"
[sideBarMode]="'sliding'"
[sideBarSide]="'right'"
[clickOutsideSidebar]="true"
[theme]="theme.dark"
[sideBarOverlap]="false"
[scrollable]="true"
[sideBarWidth]="'377px'"
[selfToggle]="true">
<!--<ng-template kennedysSidebar>
This is a template passed
</ng-template> -->
</k-sidebar>
HTML组件的ngStyle就是这样。
[ngStyle]="{'width.px': sidebar.isDesktopWidth ? sideBarWidth : '',
'margin-bottom.px': marginBottom ? marginBottom : '',
'margin-top.px': marginTop ? marginTop : '',
'top.px': top ? top : '',
'bottom.px': bottom ? bottom : ''}"
底部我可以在CSS中看到它为60px,但是,当我传递0(零)时,它在CSS中不存在。任何想法为什么会这样?我猜top(input)被视为null或其他内容
因为0是一个伪造的值。条件top ? top : ''
将始终返回false