简体   繁体   English

如何使用 VUE js 中的路径在页面之间传递数据?

[英]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 .因此,当我在edit page中单击保存按钮时,它会将用户重定向到返回add page ,并且 url 将是/test/admin/testing/add?visit_status=39 How do i retrieve this data using ID from my edit page to add page?如何使用我的编辑页面中的 ID 检索此数据以添加页面?

edit.vue

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

You can get query data like the following.您可以获得如下查询数据。 You can use for route jobs with this.$route .您可以使用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
      }
       
    }
  },

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM