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 '';
    }
  }

猜你喜欢

转载自www.cnblogs.com/mlh1421/p/11506927.html
今日推荐