1.调用子组件给子组件定义一个名称

<app-footer #footerChild></app-footer>

2. 引入 ViewChild

import { Component, OnInit ,ViewChild} from '@angular/core';

3. ViewChild 和刚才的子组件关联起来

 

 @ViewChild('footerChild') footer;

4.调用子组件

run(){ 
    this.footer.footerRun();
}

非父子组件通讯

 

1、公共的服务 2、Localstorage (推荐) 3、Cookie

 

 

 

 

相关文章:

  • 2021-05-19
  • 2021-05-31
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
  • 2021-11-02
  • 2022-02-23
  • 2021-04-30
猜你喜欢
  • 2021-07-05
  • 2022-12-23
  • 2022-12-23
  • 2019-06-20
  • 2022-12-23
  • 2021-08-23
相关资源
相似解决方案