1

I am using router-link for menu list. With that, active class is adding properly on clicking the link. I have a button in a page and it will navigate to another page using $router.push function but the active class is not removed from the previous page link and it is not added to navigated page.

btnClick: function () {
    this.$router.push({ path: '/NextPage' })
},

Can i force set active class through this.$router.push() function?

1
  • How do you set up router-link with active class? Commented Jun 6, 2018 at 9:46

1 Answer 1

1

Add linkActiveClass option while creating router object.

For e.g

const router = new VueRouter({ linkActiveClass: 'active' });

linkActiveClass is one of the route options.

https://router.vuejs.org/api/#name

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.