this.$router.push 傳參


index頁面
1.params
this.$router.push()方法中path不能與params同用,否則param會失效,所以用name來指定頁面,params來傳遞數據內容。

<template> <img src="../../static/images/indexTermianal/teacher.png" alt="" @click ="go()" > </template> <script> methods:{ go:function(){ this.$router.push({ name:'indext', params:{ userId:1 } }) } } </script>

在目標頁面通過this.$route.params獲取參數:
  <p>{{this.$route.params.userId}}</p>
 
2.query
頁面通過path和query傳遞參數,該實例中row為某行表格數據
methods:{
go:function(){
this.$router.push({
path:'/indext',
query:{
userId:1
}
})
}
},
目標頁面this.$route.query.userId獲取數據
<p>{{this.$route.query.userId}}</p>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM