core icon indicating copy to clipboard operation
core copied to clipboard

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

Open liub1934 opened this issue 1 year ago • 2 comments

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

liub1934 avatar Mar 16 '24 13:03 liub1934

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

57711 avatar Mar 16 '24 16:03 57711

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

可以不需要重定向吗

liub1934 avatar Mar 17 '24 03:03 liub1934

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[bot] avatar Apr 02 '24 01:04 github-actions[bot]