Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

228
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!