A
A
Anton89892019-10-26 11:59:31
Vue.js
Anton8989, 2019-10-26 11:59:31

How to save the parameter that is passed through router after page reload?

Good day)) The essence of the question is this - by clicking I pass the parameter through the router, the parameter is transmitted correctly, and its value is displayed, but after reloading the page, the parameter is deleted and the console is irrigated with blood)) Tell me, please, how can I save after reloading the page this parameter, I enclose the code -

Файл 1

<template>
  <div class="Scroll-Item"  v-for="(task,index) in tasks" :key="index" @click="goTask(task.id)">
    <div class="Scroll-Title">Название анкеты</div>
    <div class="Scroll-Description">Описание анкеты</div>
  </div>
</template>

<script>


<script>
import Top from '@/components/Top'

export default {
  data() {
    return {
      b: ''
    }
  },
  components: {
  	Top
  },
  computed: {
  	tasks() {
  		return this.$store.getters.tasks
  	}
  },
  methods: {
    async goTask(proId) {
    		let post = await  fetch('/article/promise-chaining/user.json')
      this.$router.push({name:'performer',params:{Pid:proId, info: post}})
  		}
  }
}

</script>




Файл 2

<template>
  <div class="Performer">
    <div class="Performer-Content">
        <div  v-for="(task,index) in tasks" :key="index">
       		<div v-if="proId == task.id">

       			<div>{{post.url}}</div>

       		</div>
   			</div>	
    </div>
  </div>
</template>



<script>

export default {
  name: 'performer',
  data(){
    return{
      proId: this.$route.params.Pid,
      post: this.$route.params.info,
}
</script> 


Файл 3 (то что в файле router.js)

import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

export default new Router({
  mode: 'history',
  base: process.env.BASE_URL,
  routes: [
    {
      path: '/performer/:Pid',
      name: 'performer',
      meta: {layout: 'main'},
      component: () => import('./views/Performer.vue')
    },
    {
      path: '/workers',
      name: 'workers',
      meta: {layout: 'main'},
      component: () => import('./views/Workers.vue')
    },
    
  ]

})

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ihor Bratukh, 2019-10-26
@BRAGA96

LoxalStorage or use router.query instead of router.params

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question