小编Tho*_*pra的帖子

为什么 Typescript 允许实现抽象类?

我会阅读有关打字稿的内容classabstract class并且确实发现了一些非常有趣的东西。

Typescript allows us to implement classes.

我什至创建了一个stackblitz项目来测试它。

无论如何,我已经在这里找到了一般差异,以及它在此处的打字稿中的行为是什么。

我知道它可以用来为测试创建模拟。

为什么打字稿允许的话,如果在其他非常流行的语言(JavaC#,...),这是“禁止”?此功能是否还有其他重要应用?

extends interface class implements typescript

5
推荐指数
1
解决办法
88
查看次数

为什么(!+ [] + [])是'true'而且(false + [])在Javascript中是'false'?

我正在查看ECMA-262语法,以获得下一个代码的定义:

const v = (! + [] + []);
const c = (false + []);

console.log(v);
console.log(c);
Run Code Online (Sandbox Code Playgroud)

什么是它?

到目前为止,我没有找到任何有用的信息,是否有人知道为什么它会给出这些结果或有关于它的参考?

javascript arrays ecmascript-6

3
推荐指数
1
解决办法
251
查看次数

Angular Material - 如何在运行时更改按钮颜色

我正在使用有角度的材料制作侧边栏菜单。我没有找到根据某些组件属性更改按钮颜色的方法。

我已经阅读了文档:https : //material.angular.io/components/button/overview

关于主题,它只说:

Buttons can be colored in terms of the current theme using the color property to set the background color to primary, accent, or warn.

这是我的代码:

<button
       *ngFor="let link of links; let i = index"
       mat-raised-button
       color="primary"
       (click)="selectedIndex = i"
       [routerLink]="link.routerLink">
</button>
Run Code Online (Sandbox Code Playgroud)

我什至不知道是否有可能,但我正在寻找这样的东西:

<button
       *ngFor="let link of links; let i = index"
       mat-raised-button
       (click)="selectedIndex = i"
       [color]="selectedIndex === i ? primary : warm"
       [routerLink]="link.routerLink">
</button>
Run Code Online (Sandbox Code Playgroud)

material-design angular-material angular

2
推荐指数
1
解决办法
2731
查看次数