angular4 组件的输入

在Angular4 里面可以通过inputs配置项来指定组件希望接收哪些参数。指定组件接收一个输入参数的方法:

通过@Input注解。先导入Input,然后把@Input()添加到属性声明上。

代码示例:

@Input() name:string

在模板使用时可以这样写:

<my-component [name] = '李四'></my-component>

 

相关文章:

  • 2021-08-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-20
  • 2022-12-23
  • 2021-09-01
  • 2021-04-03
  • 2021-08-28
  • 2022-01-20
  • 2021-11-04
相关资源
相似解决方案