vuejs / vue-router

🚦 The official router for Vue 2
http://v3.router.vuejs.org/
MIT License
18.99k stars 5.06k forks source link

Include hashtags in redirect paths #1821

Closed joakimglaving closed 7 years ago

joakimglaving commented 7 years ago

Version

2.7.0

Reproduction link

http://jsfiddle.net/xt02xun7/

Steps to reproduce

  1. Click on the /foo link.

What is expected?

It redirects to /redir, with the hashtag still in the url.

What is actually happening?

It can't find /redir#bar


I have a page which opens accordions by using hashtags, and I would like to include these hashtags in the vue routers redirect function like so: { path: '/foo', redirect: '/redir#bar' }.

Manually typing the url /redir#bar works.

It seems like the redirect tries to find the path /redir#bar, including the hashtag. What I would like to do is for it to redirect to the /redir path, with the hashtag #bar still in the URL, as if you would write the URL manually.

Is this possible?

Regards,

LinusBorg commented 7 years ago

This works: http://jsfiddle.net/3ewnh7hd/

joakimglaving commented 7 years ago

I tried it in my local environment now, but it doesn't seem to include the hash in the url though, and the accordion does not open. Do I have to do something more with the hash to make it work?

Regards,

joakimglaving commented 7 years ago

My mistake! What @LinusBorg wrote works perfectly fine :)

Can close this.