G
G
grabbee2021-01-28 11:13:19
Vue.js
grabbee, 2021-01-28 11:13:19

How to add only hash to jump address?

For example, the address /page?n=2 is already open and I want to add only #some using either router-link or programmatically via push . In this case, the page itself and the URL parameters can be different. I just need to add the hash to the end. While doing this

let route = Object.assign({}, this.$route, { hash: this.hash });
      this.$router.push(route);


But it's kind of a crutch...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Anton, 2021-01-28
@grabbee

this.$router.push({...this.$route, hash: this.hash });

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question