TabQueryHandler.vue 555 B

1234567891011121314151617181920212223242526272829
  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(
  17. key =>
  18. `${encodeURIComponent(key)}=${encodeURIComponent(
  19. queries[key]
  20. )}`
  21. )
  22. .join("&")}`
  23. );
  24. }
  25. }
  26. };
  27. </script>