zoukankan      html  css  js  c++  java
  • vue 路由传参

     1、 this.$router.push进行编程式路由跳转

        2、 router-link 进行页面按钮式路由跳转

        3、 this.$route.params获取路由传递参数

        4、this.$route.query获取路由传递参数

        5、 params 和 query 都是传递参数的,params不会在url上面出现,并且params参数是路由的一部分,是一定要存在的 query则是我们通常看到的url后面的跟在?后面的显示参数

    方法一 

    this.$router.push({
                path:"/路径名字",
                query:{
                  id:id
                }
              })
    方法二
    this.$router.push({
                 name:"/路径名字",
                 params:{
                  id:id
                }
              })
    方法三
    this.$router.push('.路径名'+id)
     
     
    路由。index.js文件
     {
          //方式一 二路由路径
          path: '/路径名',
          //方式三路由路径
          // path: '/路径名:id',
          name: 'Xq',
          component: Xq
        },
     接受传过来的参数
        方法一接收
      this.$route.query.id
     
     <!--  方法二接收  -->
     this.$route.params.id
     
     <!--  方法三接收  -->
     this.$route.params.id
  • 相关阅读:
    vue源码分析—Vue.js 源码目录设计
    vue源码分析—认识 Flow
    在Windows上安装配置MongoDB
    mongoDB概述
    Could not load file or assembly Microsoft.Web.Infrastructure
    配置错误 不能在此路径中使用此配置节(转)
    VS2013快捷键大全
    Create new tool for CSV
    How to get http response.
    C#中Split用法
  • 原文地址:https://www.cnblogs.com/jackie-song/p/12787989.html
Copyright © 2011-2022 走看看