Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

182
Vistas
How to let color of svg and span text color same

Here is my Vue code:

      <icon
          :color="itemDynamicColor"
          :data="icon"
      />
      <span v-bind:style="dynamicStyle">SpanText</span>

I want the icon and span text keep same color, as you see, I use computed property to define icon color and span color. However I think this way is a little stupid.

I wonder if there is any better way?

EDIT

Actually the color of both will change when some data change.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You could handle this all in plain CSS by using a custom property for the color you want, and then setting the color of the <icon> and <span> to that.

about 4 years ago · Juan Pablo Isaza Denunciar

0

The color of both will change when some data change.

To achieve this, you can update the dynamicStyle object in both <icon> and <span> based on the condition as per your requirement.

Demo :

new Vue({
  el: '#app',
  data: {
    dynamicColor: {
      color: 'red'
    }
  }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
  <!-- For icon you can apply same dynamicColor property dynamically -->
  <span :style="dynamicColor">SpanText</span>
</div>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda