1.引入元素選擇器
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式布局 可以全局設置容器內的頁面組件的屬性