Skip to content

括号,无括号,中括号的区别 #180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
22cgreen opened this issue Apr 2, 2022 · 1 comment
Open

括号,无括号,中括号的区别 #180

22cgreen opened this issue Apr 2, 2022 · 1 comment

Comments

@22cgreen
Copy link

22cgreen commented Apr 2, 2022

在angular我们经常看到有<ul nz-menu nzTheme="dark" nzMode="inline" [nzInlineCollapsed]="isCollapsed" (click)="test()" on-click="test2()">
1、nz-menu 没有括号没有附值。
2、nzTheme="dark"没括号有附值。
3、[nzInlineCollapsed]="isCollapsed"有中括号有附值。
4、(click)="test()" 小括号、还有不带括号的on-click
这些有什么区别?

@asnowwolf
Copy link
Contributor

asnowwolf commented Apr 2, 2022

1、nz-menu 没有括号没有附值。
应用 nz-menu 指令

2、nzTheme="dark"没括号有附值。
应用 nzTheme 指令并且把 dark 作为字符串赋值给这个指令的 nzTheme 属性(比如 @Input('nzTheme') theme: string),等价于 [nzTheme]="'dark'"

3、[nzInlineCollapsed]="isCollapsed"有中括号有附值。
应用 nzInlineCollapsed 指令,并且把 isCollapsed 属性绑定到这个指令的 nzInlineCollapsed 属性(同上)

4、(click)="test()" 小括号、还有不带括号的on-click
两者等价,不过建议只用前者。后面的版本会把后者弃用。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants