随笔 - 326,  文章 - 0,  评论 - 0,  阅读 - 16万

笔记一

  • 传参链接
      <router-link to="/home/message/detail/12?title=张三">detail</router-link>
      //12  为params 参数传递形式
      //title  为query 参数传递形式
    
  • 路由形式
      path:'detail/:id',    //params形式,params传递的参数为12
      // path:'detail',     //默认形式,query传参用的是这种形式
        component:Detail,
      // 方式一   布尔值                    
      // props:true,//将所有的params参数直接映射到props中
          //注意:这种方式只能是params传参,并且在路由接收的时候需要声明 props["id"]  来接收传递的参数值
      // 方式二 对象
      // props:{id:11,name:"张三11"}
          //注意:这种方式是自定义传参,传递的参数为死数据,并且在路由接收的时候需要声明 props["id","name"]  来接收传递的参数值
      // 方式三
      props: route => ({
        id:route.params.id,
        title:route.query.title,
        name:"自定义的值"
      })
          //注意:这种方式可以是query,也可以是params传参,并且在路由接收的时候需要声明 props["id","name"]  来接收传递的参数值
    
  • 路由接收数据
      一.this.$route  来接收
      二.props:["id","name"]
        具体视情况而定
    

笔记二

  • query传参形式

      请求:  this.$router.push("/search?keywords="+this.keywords)
      路由:  {
              path:'/search',
              component:Search
            },
      接收:  $route.query.keywords
    
  • params参数形式

      请求:  this.$router.push(`/search/${this.keywords}`)
      路由:  {
              path:'/search/:keywords',
              component:Search,
              name:"search"
            },
      接收:  {{$route.params.keywords}}
    
  • 综合

      请求:  this.$router.push({
                  name:"search",
                  query:{keywords:this.keywords},
                  params:{keywords:this.keywords.toUpperCase()}
              })
      路由:
            {
                path:'/search/:keywords',
                component:Search,
                name:"search"
            },
      接收:
            query{{$route.query.keywords}}
            params{{$route.params.keywords}}
    
posted on   文种玉  阅读(743)  评论(0编辑  收藏  举报
(评论功能已被禁用)
编辑推荐:
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· winform 绘制太阳,地球,月球 运作规律
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示