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

128
Views
How to change the style of sidebar element according to the route in vuejs

I have a sidebar, and clicking on any one of the buttons changes the route and loads a new page, which in turn changes the style of the button to active.

I always want to keep the button active according to the route. I am using the router-link-active class for it, and it works well in all the cases except when I type the route manually and load the page, or when the page is initially loaded the first button is supposed to be active, but it is not the case.

sample button:

  <li>
<router-link :to="{ name: 'Test' }">
  <sidebar-button id="Test-logo" :title="Test">
    <icon-test-logo />
  </sidebar-button>
</router-link>

css:

    `.router-link-active {
    button {
        // Active / Open
        &:active,
        &.e-active {
            background-color: #175222;
        }
    }
}`
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It seems that the &:active, &.e-active classes were not required here. Removing them resolved the issue. As these two classes were not being added to the element.

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