[英]When and for which component is the DOM created in Angular?
Does each Angular component have its own DOM? 每个Angular组件都有自己的DOM吗? Or is it only one DOM for the
index.html
, and only the component selector inside the index.html
have their template elements in the DOM? 或者它只是一个DOM的
index.html
,只有内部的组件选择index.html
必须在DOM的模板元素?
Here's the trick: 这是窍门:
Create an angular app, create a few components, use them in the app and Run the app: 创建一个有角度的应用程序,创建一些组件,在应用程序中使用它们并运行该应用程序:
You can check the actual DOM of the entire page by inspecting the page on your browser under Elements tab. 您可以通过在浏览器的“元素”选项卡下检查页面来检查整个页面的实际DOM。
I had already done that and the result is: 我已经做过,结果是:
Every component you're seeing on the screen is part of the actual DOM. 您在屏幕上看到的每个组件都是实际DOM的一部分。 So basically, though not sure but I am assuming based on my checks, All components are part of the index.html DOM.
所以基本上,虽然不确定,但是我根据检查来假设,所有组件都是index.html DOM的一部分。
I have tested this by viewing the ELements of the angular.io site and I found that every component displayed on the screen is part of the DOM. 我通过查看angular.io网站的ELements进行了测试 ,发现屏幕上显示的每个组件都是DOM的一部分。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.