BaiLinfeng
V2EX  ›  Vue.js

### `Vue`路由传参

  •  
  •   BaiLinfeng · Oct 11, 2020 · 2230 views
    This topic created in 2054 days ago, the information mentioned may be changed or developed.

    对路由传参的总结,不对之处望包涵,指正。记录Vue路由传参的两种方式query 和 params

    路由传参之-------this.$route.query

    <router-link to='/home?id=123&name=zhangsan'>路由传参 query</router-link>

    路由传参之-------``this.$route.params`

    <router-link to="/home/123/zhangsan">路由传参 params</router-link>

    • this.$route.params.id,不可以拿到 123,都需要配置路由规则为:{path:'/home/:id/:name',Component:home}
    • this.$route.params.name,也拿不到zhangsan,都需要配置路由规则为:{path:'/home/:id/:name',Component:home}
    4 replies    2020-10-14 20:33:30 +08:00
    chenpingan
        1
    chenpingan  
       Oct 12, 2020
    这种笔记的话记录到笔记之中不是更好,类似印象笔记之类的
    BaiLinfeng
        2
    BaiLinfeng  
    OP
       Oct 12, 2020
    @chenpingan 嗯,笔记里面刚也记录了,主要是知道记录的正确性。就公开这样写了。
    begoingtodo
        3
    begoingtodo  
       Oct 13, 2020
    vue 的文档不是都有的吗
    BaiLinfeng
        4
    BaiLinfeng  
    OP
       Oct 14, 2020
    @begoingtodo 说真的 vue 文档不是很白话,很多语言逼格有点高了,我有点难消化。要看民间的文章解释
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3077 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 14:04 · PVG 22:04 · LAX 07:04 · JFK 10:04
    ♥ Do have faith in what you're doing.