详情:https://www.angular.cn/guide/component-overview

  1. //1.子组件自定义属性接收父组件传递过来的参数
  2. <app-MovieItem [title]="title"></app-MovieItem>
  1. //2.在子组件中使用@Input进行注册
  2. import { Component, OnInit,Input } from '@angular/core';
  3. export class MovieItemComponent implements OnInit {
  4. @Input() title!: String;
  5. }
  1. //3.在子组件的模板中直接使用
  2. <p>{{title}}</p>