• angular 的 @ViewChild 和 @ViewChildren 区别


    ViewChild 装饰器用于获取模板视图中的元素或直接调用其组件中的方法。它支持 Type 类型或 string 类型的选择器,同时支持设置 read 查询条件,以获取不同类型的实例。

    ViewChildren 装饰器是用来从模板视图中获取匹配的多个元素,返回的结果是一个 QueryList 集合。

    static:true  用于页面初始化时就显示的数据,可以结合ngAfterViewInit使用

    static:false 用于页面动态加载模板

     

    @ViewChildren(ChildComponent,{static:true}) child
    @ViewChildren(ChildrenComponent) children:QueryList<ChildrenComponent>
  • 相关阅读:
    法院
    Spring Cloud常用组件
    PowerShell使用教程
    浅谈3DES加密解密
    SC win consul
    SB-Token-Jwt
    前端MVC Vue2学习总结
    spring-session-data-redis
    SpringBoot WS
    SpringBoot之使用Spring Session集群-redis
  • 原文地址:https://www.cnblogs.com/lskzj/p/12022432.html
Copyright © 2020-2023  润新知