Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug report] 使用router进行路由跳转会丢失query参数 #1514

Closed
liub1934 opened this issue Mar 16, 2024 · 3 comments · Fixed by #1527
Closed

[Bug report] 使用router进行路由跳转会丢失query参数 #1514

liub1934 opened this issue Mar 16, 2024 · 3 comments · Fixed by #1527
Assignees
Labels
bug Something isn't working

Comments

@liub1934
Copy link

Description

组件中使用router进行路由跳转会丢失query参数,如下的代码所示,实际跳过去的页面后面没有query的参数,可以通过下面的复现链接点击页面中的测试按钮查看效果。不知道是从哪个版本就失效了,之前一直是有用的。

<template>
  <button style="width: 200px; height: 30px" @click="testClick">测试</button>
</template>

<script setup lang="ts">
import { useRouter } from 'vue-router';

const router = useRouter();

function testClick() {
  router.push({
    path: '/test',
    query: {
      type: '123',
    },
  });
}
</script>

Reproduction

https://stackblitz.com/edit/vuepress-auhtn4

Used Package Manager

pnpm

System Info

MacOS 13.5.2
Chrome 122.0.6261.112
@57711
Copy link

57711 commented Mar 16, 2024

这里路由发生了重定向,在redirectedFrom中可以拿到query

@liub1934
Copy link
Author

这里路由发生了重定向,在redirectedFrom中可以拿到query

可以不需要重定向吗

Copy link

github-actions bot commented Apr 2, 2024

This issue is marked as stale because it has not had recent activity. Issues marked with stale will be closed if they have no activity within 7 days.

@github-actions github-actions bot added the stale label Apr 2, 2024
@Mister-Hope Mister-Hope added bug Something isn't working and removed stale labels Apr 4, 2024
@Mister-Hope Mister-Hope linked a pull request Apr 6, 2024 that will close this issue
@Mister-Hope Mister-Hope self-assigned this Apr 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants