1.引入元素选择器

Angular使用 ElementRef + Renderer2 全局设置组件属性

 

 

 

2.使用angular钩子全局设置input长度

ngAfterViewChecked() {
    const input = this.el.nativeElement.querySelectorAll('input');
    if (input) {
      input.forEach(e => {
        this.renderer.setAttribute(e, 'maxlength', '1');
        // console.log(e);
      });
    }
  }

3.如果项目是采用framework式布局 可以全局设置容器内的页面组件的属性

Angular使用 ElementRef + Renderer2 全局设置组件属性

 

 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-05
  • 2021-11-19
  • 2021-07-30
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案