Skip to content
Advertisement

How do I set a route in hash mode with params with Vue Router 3 (Vue 2)

Currently, my Vue router is using hash mode for my router and I am looking for a way to pass parameters when generating links to another component. so far I came up with this:

this is what it currently looks like in my Markup:

JavaScript

I am passing down the article id into the link so that when the user clicks on the button, it will direct him to a component where the article with the respective id is visible with its content.

the problem comes when setting up routes, below is my index.js under router

JavaScript

As you can see for the /article/:id path I am trying to link it with the ArticlePageComponent. The problem is that /article/:id doesn’t seem to work for hash modes, it will just redirect me to the homepage. Any suggestions?

Advertisement

Answer

Instead of having href in b-button why don’t have a handler in methods like

JavaScript

and trigger it on click event

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement