Angular8:[attr.title]='myVar' 和 [title]='myVar' 有什么区别?

Angular8: What is the difference between [attr.title]='myVar' and [title]='myVar'?

为什么有些属性需要“attr.”有前缀有的没有?

简短回答:[title]="myVar" 是 属性 绑定,而 [attr.title]="myVar" 是属性绑定。

当 DOM 属性 不存在时,必须使用属性绑定。 例如,colspan 不存在 DOM 属性,您必须使用 attr.colspan="..."。当您尝试使用 colspan="..." 时,您会在控制台中收到错误消息。 继续阅读 attribute binding here