vue获取链接后参数

跳转的时候给参数

<router-link :to="{ path: '/t', query: { accid: 1111}}">click to news page</router-link>

获取参数
刷新页面不会丢失参数

let accid = this.$route.query.accid
<router-link :to="{ path: '/t', params: { accid: 1111}}">click to news page</router-link>```

获取参数
刷新页面会丢失参数

let accid = this.$route.params.accid

跳转页面

//传参 跳转页面 已get形式跟在了链接后面
this.$router.push({
        path:'/xxx',
        query:{
          id:id
        }
      })
  
//接收参数:
this.$route.query.id
//传参 跳转页面 已post的形式看不到参数 
this.$router.push({
        path:'/xxx',
        params:{
          id:id
        }
      })
  
//接收参数:
this.$route.params.id

猜你喜欢

转载自blog.csdn.net/j244233138/article/details/102922226