ElementReflink
安全风险
Permitting direct access to the DOM can make your application more vulnerable to XSS attacks. Carefully review any use of ElementRef
in your code. For more detail, see the Security Guide.
允许直接访问 DOM 会导致你的应用在 XSS 攻击前面更加脆弱。要仔细评审对 ElementRef
的代码。欲知详情,参见安全。
构造函数
参数
|
属性
属性名 | 类型 | 说明 |
---|---|---|
nativeElement | The underlying native element or 背后的原生元素,如果不支持直接访问原生元素,则为 Use this API as the last resort when direct access to DOM is needed. Use templating and data-binding provided by Angular instead. Alternatively you can take a look at 当需要直接访问 DOM 时,请把本 API 作为最后选择。优先使用 Angular 提供的模板和数据绑定机制。或者你还可以看看 Relying on direct DOM access creates tight coupling between your application and rendering layers which will make it impossible to separate the two and deploy your application into a web worker. 如果依赖直接访问 DOM 的方式,就可能在应用和渲染层之间产生紧耦合。这将导致无法分开两者,也就无法将应用发布到 Web Worker 中。 |