英文:
Shadow dom parts not working with Child combinator
问题
*.html*
<ion-select
mode="md"
formControlName="sortBy"
interface="popover"
legacy="true"
>
<ion-select-option value="1">最新</ion-select-option>
<ion-select-option value="5">价格(从高到低)</ion-select-option>
</ion-select>
.css
.my-class>ion-select::part(icon) {
display: none !important;
}
英文:
.html
<ion-select
mode="md"
formControlName="sortBy"
interface="popover"
legacy="true"
class="my-class"
>
<ion-select-option value="1">Newest</ion-select-option>
<ion-select-option value="5">Price (High to Low)</ion-select-option>
</ion-select>
.css
.my-class>ion-select::part(icon) {
display: none !important;
}
Can you tell me why the above is not working? But this works:
ion-select::part(icon) {
display: none !important;
}
I need to add the my-class dynamically here. That is why I need this.
答案1
得分: 1
你正在使用 > 选择器,这意味着你在说 ion-select 需要是 .my-class 的直接子元素。然而,实际情况并非如此,查看HTML结构。
请使用 ion-select.my-class::part(icon)。
英文:
You are using the > selector, by which you are saying that ion-select needs to be a direct child of .my-class.
This is not the case, looking at the HTML structure
Please use ion-select.my-class::part(icon)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。



评论