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

232
Vistas
Applying dynamic theme in vuejs

I am trying to change theme dynamically in vueJs, I'll get color code from API, and I want to change theme according to that.

right now I've done like this.

in util.js

var ChangeTheme = {
    applyTheme_fn(color) {
        document.querySelector(".navbar .navbar-collapse").style.color = color
        ...
    }
} 

export default ChangeTheme

in home.vue


import ChangeTheme from '@/components/util.js'
....
methods: {
    someMethod() {
        let themeColor = data.response.themeColor // color code from API response
        ChangeTheme.applyTheme_fn(themeColor)
    }
}

This works at some places, but not in all places. If I write style in particular component it works there. but querySelector is not applying at all places.

is there any workaround for this?

about 4 years ago · Juan Pablo Isaza
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