gpt4 book ai didi

vue.js - Vue 路由器警告消息 "passed with params but they will be ignored"

转载 作者:行者123 更新时间:2023-12-04 17:17:08 24 4
gpt4 key购买 nike

我在分支“added-vuex-to-ssr”上运行以下示例应用程序
https://github.com/se22as/vue-3-with-router-basic-sample
当我使用 SSR 运行示例应用程序时,当我转到主页或关于页面时,会收到以下 Vue Router 警告。找不到警告的文档。任何帮助,将不胜感激。
[Vue Router 警告]:路径“/”与参数一起传递,但它们将被忽略。改为在 params 旁边使用命名路由。
[Vue Router 警告]:路径“/about”与参数一起传递,但它们将被忽略。改为在 params 旁边使用命名路由。

最佳答案

该警告基本上是让您知道您需要使用 named route如果你想传递参数,而不是路径。
所以,而不是 this.$router.push({path:'/', params: { param: someValue } })和:

routes: [
{
path: '/',
component: Home
}
你会做类似 this.$router.push({name:'Home', params: { param: someValue } }) 的事情和:
routes: [
{
path: '/',
name: 'Home',
component: Home
}
更多信息:
  • how to use vue-router params
  • https://router.vuejs.org/guide/essentials/passing-props.html
  • 关于vue.js - Vue 路由器警告消息 "passed with params but they will be ignored",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68435072/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com