user1903219
user1903219

Reputation: 141

Vue Router warning message "passed with params but they will be ignored"

I'm running the following sample application on branch "added-vuex-to-ssr"

https://github.com/se22as/vue-3-with-router-basic-sample

When I run the sample application with SSR, I get the following Vue Router Warnings when I go to the home or about page. Can't find documentation for the warnings. Any help would be appreciated.

[Vue Router warn]: Path "/" was passed with params but they will be ignored. Use a named route alongside params instead. [Vue Router warn]: Path "/about" was passed with params but they will be ignored. Use a named route alongside params instead.

Upvotes: 14

Views: 14203

Answers (1)

jeffrey.d.m
jeffrey.d.m

Reputation: 867

The warning is basically letting you know that you need to use a named route instead of a path if you want to pass parameters.

So instead of this.$router.push({path:'/', params: { param: someValue } }) and:

routes: [
  {
    path: '/',
    component: Home
  }

You would do something like this.$router.push({name:'Home', params: { param: someValue } }) and:

routes: [
  {
    path: '/',
    name: 'Home',
    component: Home
  }

Some more info:

Upvotes: 10

Related Questions