为v-select组件更改图标颜色。

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

Change icon color for v-select component

问题

I set an icon to v-select component but I want to change its color to red.

<v-select
  :items="items"
  label="Standard"
  prepend-icon="edit"
></v-select>

How to colorize the icon ?

英文:

I set an icon to v-select component but I want to change its color to red.

为v-select组件更改图标颜色。

<div id="app">
  <v-app id="inspire">
    <v-container fluid>
      <v-row align="center">
        <v-col class="d-flex" cols="12" sm="6">
          <v-select
            :items="items"
            label="Standard"
            prepend-icon="edit"
          ></v-select>
        </v-col>
      </v-row>
    </v-container>
  </v-app>
</div>

Codepen

How to colorize the icon ?

答案1

得分: 6

只需使用插槽 prepend

<v-select
  :items="items"
  label="Standard">
  <template v-slot:prepend>
    <v-icon color="red">edit</v-icon>
  </template>
</v-select>
英文:

Just use the slot prepend

&lt;v-select
  :items=&quot;items&quot;
  label=&quot;Standard&quot;&gt;
  &lt;template v-slot:prepend&gt;
    &lt;v-icon color=&quot;red&quot;&gt;edit&lt;/v-icon&gt;
  &lt;/template&gt;
&lt;/v-select&gt;

答案2

得分: 2

请查看Vuetify文档。
https://vuetifyjs.com/en/components/selects#selects

如果您检查示例,HTML部分是:

&lt;i aria-hidden=&quot;true&quot; class=&quot;v-icon notranslate material-icons theme--light&quot;&gt;map&lt;/i&gt;

Vuetify有用于颜色的抽象类。在这种情况下是:.theme--light.v-icon
颜色的文档在这里:
https://vuetifyjs.com/en/styles/colors#

在那里,您可以选择所需的颜色,并通过Sass进行更改。
此外,您可以这样设置它:

.v-icon {
  color: ##0F0F0F;
}
英文:

Check Vuetify documentation.
https://vuetifyjs.com/en/components/selects#selects

If you inspect the example, the html is:

&lt;i aria-hidden=&quot;true&quot; class=&quot;v-icon notranslate material-icons theme--light&quot;&gt;map&lt;/i&gt;

Vuetify has abstract classes for colors. In this case: .theme--light.v-icon
The documentation of colors is:
https://vuetifyjs.com/en/styles/colors#

There you could select the color you want and via sass change it.
Furthermore, you could set it like:

.v-icon {
  color: ##0F0F0F;
}

答案3

得分: 0

你可以使用Markup简单地改变颜色

    &lt;div id=&quot;app&quot;&gt;
      &lt;v-app id=&quot;inspire&quot;&gt;
        &lt;v-container fluid&gt;
          &lt;v-row align=&quot;center&quot;&gt;
            &lt;v-col class=&quot;d-flex&quot; cols=&quot;12&quot; sm=&quot;6&quot;&gt;
              &lt;v-select
                :items=&quot;items&quot;
                label=&quot;标准&quot;
                prepend-icon=&quot;edit&quot;
              &gt;
                 &lt;template v-slot:prepend&gt;
                  &lt;v-icon color=&quot;绿色&quot;&gt;edit&lt;/v-icon&gt;
                &lt;/template&gt;
              &lt;/v-select&gt;
              
            &lt;/v-col&gt;
          &lt;/v-row&gt;
        &lt;/v-container&gt;
      &lt;/v-app&gt;
    &lt;/div&gt;

查看链接: https://codepen.io/pen/BaymmWQ

英文:

You can change color simply using Markup

    &lt;div id=&quot;app&quot;&gt;
      &lt;v-app id=&quot;inspire&quot;&gt;
        &lt;v-container fluid&gt;
          &lt;v-row align=&quot;center&quot;&gt;
            &lt;v-col class=&quot;d-flex&quot; cols=&quot;12&quot; sm=&quot;6&quot;&gt;
              &lt;v-select
                :items=&quot;items&quot;
                label=&quot;Standard&quot;
                prepend-icon=&quot;edit&quot;
              &gt;
                 &lt;template v-slot:prepend&gt;
                  &lt;v-icon color=&quot;green&quot;&gt;edit&lt;/v-icon&gt;
                &lt;/template&gt;
              &lt;/v-select&gt;
              
            &lt;/v-col&gt;
          &lt;/v-row&gt;
        &lt;/v-container&gt;
      &lt;/v-app&gt;
    &lt;/div&gt;

See link: https://codepen.io/pen/BaymmWQ

huangapple
  • 本文由 发表于 2020年1月3日 21:13:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/59579232.html
匿名

发表评论

匿名网友

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

确定