vue之this.$route.params和this.$route.query的區別


1.this.$route.query的使用

A、傳參數:

this.$router.push({
         path: '/monitor',
         query:{
               id:id,
          }
})
B、獲取參數:
this.$route.query.id
C、在url中形式(url中帶參數)
http://172.19.186.224:8080/#/monitor?id=1
D、 頁面之間用路由跳轉傳參時,刷新跳轉后傳參的頁面,數據還會顯示存在(項目中遇到此問題)
 
2. this.$route.params的使用

A、傳參數:

this.$router.push({
         name: 'monitor',
         params:{
               id:id,
          }
})
B、獲取參數:
this.$route.params.id
C、在url中形式(url中不帶參數)
http://172.19.186.224:8080/#/monitor
D、 頁面之間用路由跳轉傳參時,刷新跳轉后傳參的頁面,數據不存在(項目中遇到此問題)
 

 


免責聲明!

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



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