ionic4 ion-select 去掉默认的箭头
作者:互联网
ionViewDidEnter() { let select_elements = (this.el.nativeElement.querySelectorAll('ion-select')); const styles = ` .select-icon, .select-icon-inner { display: none; } .select-placeholder { color: #bfbfbf; } `; select_elements.forEach((element) => { this.injectStyles(element, '.select-icon', styles); }); }
injectStyles( shadowRootElement: HTMLElement, insertBeforeSelector: string, styles: string ) { const root = shadowRootElement.shadowRoot; const newStyleTag = document.createElement('style'); newStyleTag.innerHTML = styles; root.insertBefore(newStyleTag, root.querySelector(insertBeforeSelector)); }
github上有个injectStyles库函数,但是实现有问题,我看了一下它的源码,自己实现了一下,就是上面这个injectStyles()。
标签:styles,const,ionic4,newStyleTag,ion,injectStyles,select,icon 来源: https://www.cnblogs.com/johnjackson/p/11927777.html