0

I have crated one route for Login. But it gives error in router.push

{ path: '/login', component: () => import('pages/LoginPage.vue'), name:'Login', props: true },

When I do router.push

this.$router.push({ name: 'Login', params: { test: 'eduardo' }, replace: true })

it gives error.

[Vue Router warn]: Discarded invalid param(s) "test" when navigating.

boot file

import { route } from 'quasar/wrappers'
import { createRouter, createMemoryHistory, createWebHistory, createWebHashHistory } from 'vue-router'
import routes from './routes'

/*
 * If not building with SSR mode, you can
 * directly export the Router instantiation;
 *
 * The function below can be async too; either use
 * async/await or return a Promise which resolves
 * with the Router instance.
 */

export default route(function (/* { store, ssrContext } */) {
  const createHistory = process.env.SERVER
    ? createMemoryHistory
    : (process.env.VUE_ROUTER_MODE === 'history' ? createWebHistory : createWebHashHistory)

  const Router = createRouter({
    scrollBehavior: () => ({ left: 0, top: 0 }),
    routes,

    // Leave this as is and make changes in quasar.conf.js instead!
    // quasar.conf.js -> build -> vueRouterMode
    // quasar.conf.js -> build -> publicPath
    history: createHistory(process.env.VUE_ROUTER_BASE)
  })

  return Router
})
6
  • I guess you need to add :test to the path in your routes. With params your using dynamic routing. Maybe you want to use query instead of params, looking at your use case. Commented Nov 16, 2022 at 5:38
  • I don't think it's required. stackoverflow.com/a/45151854/9272654 Commented Nov 16, 2022 at 5:43
  • That’s an answer from 2018. I think handling props has changed since than. router.vuejs.org/guide/essentials/passing-props.html Commented Nov 16, 2022 at 5:49
  • But then I think the problem is Let's say I pass dict and it will still treat as string not object Commented Nov 16, 2022 at 5:58
  • 1
    Do you even need props: true? Maybe it expects something else than true, like 'test'? v3.router.vuejs.org/api/#route-object-properties Also, with Quasar you maybe don't even need to specify those as with Nuxt? Commented Nov 21, 2022 at 3:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.