【问题标题】:Ionic 5 build with --prod flag fails - Property 'translate' does not exist on type带有 --prod 标志的 Ionic 5 构建失败 - 类型上不存在属性“翻译”
【发布时间】:2021-03-02 19:46:39
【问题描述】:

我正在开发一个 Ionic 5 项目,当我使用 --prod 标志运行构建时,我收到以下错误:

Error: src/app/pages/edit-profile/edit-profile.page.html(8,142): Property 'translate' does not exist on type 'EditProfilePage'.

我已经追溯到下面一行:

<ion-input clearInput formControlName="userName" (ionBlur)="checkUserName($event.target.value)" (ionFocus)="userNameFocus()" placeholder="{{'USERNAME' || translate}}"></ion-input>

当我删除这一行时,带有 --prod 标志的构建是成功的。它也可以在没有 --prod 标志的情况下构建。

这是我的 tsconfig.ts 文件:

 {
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "module": "es2020",
    "moduleResolution": "node",
    "importHelpers": true,
    "target": "es2015",
    "lib": ["es2018", "dom"],
    "resolveJsonModule": true
  },
  "angularCompilerOptions": {
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true
  },
  "exclude": [".history/*"]
}

你有什么想法吗?

【问题讨论】:

    标签: javascript angular ionic-framework


    【解决方案1】:

    这是因为 prod 标志比其他标志具有更严格的构建时间规则。您应该像这样使用单个管道:

    {{'USERNAME' | translate}}
    

    https://angular-translate.github.io/docs/#/guide

    【讨论】:

      猜你喜欢
      • 2020-07-05
      • 2018-10-04
      • 2021-05-13
      • 1970-01-01
      • 2018-07-07
      • 1970-01-01
      • 1970-01-01
      • 2018-07-12
      • 2021-03-05
      相关资源
      最近更新 更多