1. 程式人生 > >vue頁面跳轉傳值

vue頁面跳轉傳值

play win created table 詳情 seq color use ESS

第一種方式:例:消息列表頁跳轉: methods: {   goTo(){     this.$router.push({       name:‘/My/Info‘,       query:{         ‘tellSeq‘:this.tableData[index].TellSeq, //跳路由         ‘menu‘:JSON.stringify(this.menuList), //傳值,必須用stringify,否則,跳轉頁面刷新,數據會消失       }     });   }, } 消息詳情頁收值: let menuToken = JSON.parse(this.$route.query.menu); 第二種方式:例:用戶登錄跳轉首頁
window.sessionStorage.setItem(‘userInfo‘, JSON.stringify(res.data)); //登錄接口發通後,存儲用戶信息到本地緩存; created() { let userInfo = JSON.parse(window.sessionStorage.getItem(‘userInfo‘)); // 登錄後,在首頁獲取用戶登錄信息: } 第三種方式:子組件和父組件之間傳值,參考: https://www.cnblogs.com/linxin/p/7144123.html

vue頁面跳轉傳值