我设置了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-Templates中正确设置它(以避免错误)?
发布于 2020-10-20 16:39:59
将属性名括在方括号中。如果不使用括号,这些值将被解释为字符串。使用方括号时,值被解释为TypeScript,因此类型正确。
<textarea matInput [matAutosizeMaxRows]="4" [matTextareaAutosize]="true"https://stackoverflow.com/questions/64441455
复制相似问题