vue 路由傳參為對象時如何處理?


通過轉換傳遞json字符串來實現傳遞,接收時再轉換回來。

傳遞時代碼:

let strItem = JSON.stringify(item);
this.$router.push(`/detail/` + encodeURIComponent(strItem));

 接收時的處理:

 let info = decodeURIComponent(this.$route.params.id);
 this.detail= JSON.parse(info);

  

  


免責聲明!

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



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