angular 父子组件传值 用get set 访问器设置默认值

  private _PLACEHOLDER: string;
  @Input()
  public set placeholder(v: string) {
    this._PLACEHOLDER = v;
  }

  public get placeholder(): string {
    if (this._PLACEHOLDER) {
      return this._PLACEHOLDER;
    } else {
      return '';
    }
  }

 

posted @ 2019-09-11 16:16  liliyou  阅读(711)  评论(0编辑  收藏  举报