![](/img/trans.png)
[英]Property 'NameNews' does not exist on type using ng build --prod
[英]Ionic 5 build with --prod flag fails - Property 'translate' does not exist on type
我正在開發一個 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/*"]
}
有什么想法嗎?
這是因為 prod 標志比其他標志具有更嚴格的構建時間規則。 您應該像這樣使用單個 pipe :
{{'USERNAME' | translate}}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.