Angular-Anwendung ohne Anmerkungen
P粉939473759
P粉939473759 2023-11-10 10:51:51
0
2
534

Gibt es eine Konfigurationseinstellung zum Entfernen dieser leeren Kommentare und Leerzeichen?

Mein Build-Befehl ist ng build --environment prod --progress false --target production und tsconfig ist:

{
    "compileOnSave": false,
    "compilerOptions": {
        "alwaysStrict": true,
        "baseUrl": "/",
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "forceConsistentCasingInFileNames": true,
        "lib": [ "es2015", "dom" ],
        "module": "es2015",
        "moduleResolution": "node",
        "newLine": "CRLF",
        "noFallthroughCasesInSwitch": true,
        "noImplicitAny": true,
        "noImplicitReturns": true,
        "noUnusedLocals": true,
        "noUnusedParameters": false,
        "outDir": "./dist/out-tsc",
        "removeComments": true,
        "skipDefaultLibCheck": true,
        "skipLibCheck": true,
        "strictNullChecks": true,
        "target": "es5",
        "typeRoots": [ "./node_modules/@types" ]
    }
}

@angular/cli:1.0.4

Knoten: 7.2.1

Betriebssystem: win32 x64

@angle/common: 4.1.3

Vielen Dank.

P粉939473759
P粉939473759

Antworte allen(2)
P粉978551081

这些注释中的每一个都是一个 ViewContainerRef,Angular 使用它来保留可以渲染视图的表达式的位置。

当你有一个 ngIf 时,如果表达式被计算为 false,显然 Angular 不会渲染该元素,但是一旦它变为 true,它就会渲染该元素,那么它是如何知道的把它放在哪里?

当然还有其他表达式求值和视图模板绑定,但 ngIf 是最容易理解的

这就是这些评论的来源。

P粉994092873

这是根据您的 Angular 指令、标签、条件(if、for...)生成的,因此此空格是必需的。如果您删除它,那么它的表现将不会很好,所有两种方式的绑定都会消失。这些空间决定您的角度 DOM 将如何渲染并绑定到模型和变量。另外,注释跟踪新 DOM 元素将呈现的位置(如果条件和其他)。

请参阅此链接以获取更多信息:https://github.com/angular/angular .js/issues/8722

Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!