vuepress / core

Vue-Powered Static Site Generator
https://vuepress.vuejs.org
MIT License
2.29k stars 926 forks source link

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

Closed liub1934 closed 5 months ago

liub1934 commented 6 months ago

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 commented 6 months ago

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

liub1934 commented 6 months ago

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

可以不需要重定向吗

github-actions[bot] commented 6 months ago

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.