Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

131
Visualizações
Vue passing data from one page to the next

On my one page I have a table, where the following runs after clicking a row:

  public onRowDataClick(workItem){    
  this.$router.push({
    path: '/SecondPageView',
    params: {pushedData: workItem}
   });
  }

This is my route:

    {
        path: '/SecondPageView',
        name: 'SecondPage',
        component: SecondPage,
        meta: {
            requiresAuth: true,
        },
    },

The next page loads fine, and now I want to be able to use the pushedData, but I'm not entirely sure how this should go.

I tried following the previous stackoverflow answer here, but I can't set it up in the same way due to how my class is set up? It wont let me have props: after my export default ....

Based on reading material here and the previous answer, I have set up the following:

<template>
...
</template>

<script lang="ts">

import ...

const GreetingProps = Vue.extend({
  props: ['pushedData']
});

@Component({
  components: {
...
  },
})  

export default class Dashboard extends GreetingProps {    
  @Watch('buttonClicked')
  Log() {
    console.log(this.pushedData);
  }
}
</script>

This returns "undefined". What can I do to be able to get my data object from one page to another?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

params is for path parameter.

If you have a route like this: /user/:id

You can do $router.push({ name: 'user', params: { id: 'abc123' })

and you can access the dynamic parameter's value via $route.params.id (no r on the $route).

If path parameter is not necessary, you can also just use query string:

router.push({ path: 'register', query: { plan: 'private' } })

It will result in: /register?plan=private

You can then access the value via $route.query.plan

Docs: https://router.vuejs.org/guide/essentials/navigation.html

Although honestly you can simply just do:

$router.push('/user/abc123') or $router.push('/register?plan=private')

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda