首页 > 解决方案 > TS2322:类型“自动”不能分配给类型“方向”

问题描述

当我dir="auto"在 Angular 10 项目的 html 文件中使用时。

<span dir="auto">

当我启用时(特别是启用时)运行ng build时,出现错误strictTemplatesstrictAttributeTypesTS2322: Type '"auto"' is not assignable to type 'Direction'

//tsconfig.json
{
  "compilerOptions":{...},
  "angularCompilerOptions": {
    "strictTemplates": true, //<--- this
    "enableIvy": true
  }
}

在 HTML5 规范中,“auto”对dir属性有效。

打字稿版本:4.0.2

标签: htmlangulartypescript

解决方案


推荐阅读