Shadow DOM 部分与子组合器不起作用。

huangapple go评论62阅读模式
英文:

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.

Shadow DOM 部分与子组合器不起作用。

答案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)

huangapple
  • 本文由 发表于 2023年5月18日 03:14:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/76275506.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定