I set strictTemplates:true
并在 HTML 模板中使用以下内容
<textarea matInput matAutosizeMaxRows="4" matTextareaAutosize="true"
我从编译器收到
error TS2322: Type 'string' is not assignable to type 'number'.
error TS2322: Type 'string' is not assignable to type 'boolean'.
但是如何在 HTML 模板中正确设置它(以避免错误)?
将属性名称括在括号中。如果保留括号,这些值将被解释为字符串。使用括号时,值将被解释为 TypeScript,因此可以正确键入。
<textarea matInput [matAutosizeMaxRows]="4" [matTextareaAutosize]="true"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)