vue平行組件傳值 params


 

歡迎加入前端交流群交流知識&&獲取視頻資料:749539640

 

需要傳值的組件組件:

 1 <template>
 2     <div>
 3       <router-link :to="{ name: 'twdetails', params: { id: a }}"  >
 4          
 5       </router-link>
 6     </div>
 7 </template>
 8 
 9 <script type="text/ecmascript-6">
10     export default {
11       data(){
12         return{
13           a:1
14         }
15       }
16     }
17 </script>

接收值的組件:

 

 1 <script>
 2 export default {
 3 
 4    data(){
 5      return{
 6        id:0
 7      }
 8    },
 9    mounted(){
10         console.log('id: ' + this.$route.params.id);
11          this.id=this.$route.params.id
12 
13    }
14 
15 }
16 
17 </script>   

 

  接收值的組件在mounted里

this.$route.params
就可以取到值

 


免責聲明!

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



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