vue傳值的編碼與解碼

編碼:encodeURIComponent()

skip(){
  this.$router.push({
  path:'./channelPromotion?channelName='+'我是字 
  段'+'&&channelUrl='+encodeURIComponent('https://www.baidu.com/#/rejister.........')
  })
}

解碼:decodeURIComponent()

mounted(){
    let channelUrl=decodeURIComponent(this.$route.query.channelUrl)
    console.log(channelUrl)
}

編碼之後的數據

%7B%22loginId%22%3A%22111111%22,%22cCode%22%3A%22123456%22,%22name%22%3A%22%E7%94%A8%E6%88%B7%E5%A7%93%E5%90%8D%22,%22gender%22%3A%22M%22,%22college%22%3A%22%E5%AD%A6%E5%91%98%E5%90%8D%E7%A7%B0%22,%22major%22%3A%22%E4%B8%93%E4%B8%9A%E5%90%8D%E7%A7%B0%22,%22className%22%3A%22%E7%8F%AD%E7%BA%A7%E5%90%8D%E7%A7%B0%22%7D

解碼之後的數據

{"loginId":"111111","cCode":"123456","name":"用戶姓名","gender":"M","college":"學員名稱","major":"專業名稱","className":"班級名稱"}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章