sách gpt4 ăn đã đi

angular - Angular 文档中描述的有关 Angular 组件装饰器行为的歧义

In lại 作者:搜寻专家 更新时间:2023-10-30 21:34:21 32 4
mua khóa gpt4 giày nike

我是 Angular 的新手,目前我已经看过 angular.io 网站提供的一些示例。但是在component decorator在文档中的解释,它指出

Angular components are a subset of directives, always associated with a template. Unlike other directives, only one component can be instantiated per an element in a template.

模板中的每个元素只能实例化一个组件的实际含义。

谁能给我解释一下。

câu trả lời hay nhất

这实际上意味着在 Angular 生态系统中,模板中的每个元素(选择器)只会实例化一个组件。检查以下示例。

//app.component.ts
import { Component } from '@angular/core';

@Component({
selector: 'app-root',
template: `

Welcome to {{ title }}!
`,
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'Test App';
}

尝试在 index.html 中使用两个选择器标签



<đầu>

Angular App







因此,您将看到只有一个 Welcome to the Test App 在浏览器中呈现。每个 html 元素只能有一个组件

关于angular - Angular 文档中描述的有关 Angular 组件装饰器行为的歧义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54058589/

32 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress