angular中括号的意义,还是通过我们之前封装的tabbar来分析
<app-scrollable-tab [menus]="topMenus" backgroundColor="green" titleColor="#fff" tilteActiveColor="yellow"
(tabSelected)="handleTabSelected($event)">
</app-scrollable-tab>
组件内部接收background的属性 接收颜色的字符串
@Input() backgroundColor = '#fff';
//使用的地方
<ul [ngStyle]="{ 'background-color': backgroundColor }">
</ul>
当前写法正常使用,如果把backgroundColor加上[]就需要这么写
<app-scrollable-tab [menus]="topMenus" [backgroundColor]="'green'" titleColor="#fff" tilteActiveColor="yellow"
(tabSelected)="handleTabSelected($event)">
</app-scrollable-tab>
代码分析,因为最终backgroundColor需要的是一个字符串,但是如果加了[]就代表属性绑定,green就代表了一个全局变量。而不是代表颜色的字符串,所以需要加上两个单引号