Gavin Teo Juen
Gavin Teo Juen

Reputation: 320

How to pass data from page to page using path in VUE js?

Currently , i have two pages which consisted of add and edit page. I want to push my data from edit page to add page. So when i click save button in edit page , it will redirect user to back add page and the url will be /test/admin/testing/add?visit_status=39. How do i retrieve this data using ID from my edit page to add page ?

edit.vue

this.$router.push({path: '/test/admin/testing/add', query:{visit_status:this.$route.params.id}})```

Upvotes: 0

Views: 174

Answers (1)

Halil
Halil

Reputation: 263

You can get query data like the following. You can use for route jobs with this.$route. Click here for more information.

data(){
    return{
      visitStatus:null
    }
  },
  created(){
    this.visitStatus=this.$route.query.visit_status
  },

Or:

You can use this directly.

methods:{
    test(){
      if(this.$route.query.visit_status){
        //process
      }
       
    }
  },

Upvotes: 1

Related Questions