2
0

TabQueryHandler.vue 556 B

12345678910111213141516171819202122232425262728
  1. <script>
  2. export default {
  3. methods: {
  4. showTab(tab) {
  5. const queries = this.$route.query.tab
  6. ? this.$route.query
  7. : { ...this.$route.query, tab };
  8. queries.tab = tab;
  9. this.$route.query.tab = tab;
  10. this.tab = this.$route.query.tab;
  11. // eslint-disable-next-line no-restricted-globals
  12. history.pushState(
  13. {},
  14. null,
  15. `${this.$route.path}?${Object.keys(queries)
  16. .map(key => {
  17. return `${encodeURIComponent(key)}=${encodeURIComponent(
  18. queries[key]
  19. )}`;
  20. })
  21. .join("&")}`
  22. );
  23. }
  24. }
  25. };
  26. </script>