选择离子的离子4离子选择设置自定义图标

时间:2019-05-01 07:42:07

标签: javascript css angular ionic-framework ionic4

我需要设置一个自定义图标以进行离子选择。以下是我的代码和输出

<ion-item class="input-container" align-items-center no-padding>
        <ion-label position="floating" no-margin no-padding>I am a</ion-label>
        <ion-select formControlName="role" mode="ios" okText="Okay" cancelText="Cancel">
          <ion-select-option value="Admin">Admin</ion-select-option>
          <ion-select-option value="Customer">Customer</ion-select-option>
        </ion-select>
        <ion-icon color="primary" name="arrow-down" mode="ios" slot="end"></ion-icon>
</ion-item>

enter image description here

是否还有其他设置自定义图标的方法,或者有人可以建议删除select-icon-inner的方法

3 个答案:

答案 0 :(得分:3)

在ionic v4中,一种解决方法是通过.scss文件隐藏图标。

ion-select::part(icon) {
  display: none !important;
}

ion-select::part(text) {
  background-image: url(<ImageUrl>);
  background-position: right;
  background-repeat: no-repeat; 
}

答案 1 :(得分:1)

这在 i5 中对我有用:

ion-select::part(icon) {
  opacity: 1;
  margin-left: 1em;
  color: transparent;
  background: url('assets/icons/light-mode/expand-down.svg') no-repeat center;
}

答案 2 :(得分:0)

这不是一个适当的解决方案,但仍然可以解决此问题。 在.scss文件中应用此样式-

ion-select {
  min-width: 100vw;
}