您现在的位置是:网站首页> 编程资料编程资料

vue传值的编码和解码方式_vue.js_

2023-05-24 437人已围观

简介 vue传值的编码和解码方式_vue.js_

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) }

用vue时前端传值带有特殊符号的,到后台却被转义了

终于解决

废话不多说。之前在写前端时,看了控制台数据传输时正常的10018-001->,但是到了后台直接变成了10018-001->当时抓狂了!!!

最后在伟大的度娘上找到了解决方法!!!!

最后利用java的StringEscapeUtils.unescapeHtml4,成功解决问题!

直接上代码

String s = StringEscapeUtils.unescapeHtml4(bomNo)

接收bomNo进行编译成String的s

这样就行了!!!

引入的包

import org.apache.commons.text.StringEscapeUtils;

maven里pom文件

             org.apache.commons             commons-text             1.1         

以上为个人经验,希望能给大家一个参考,也希望大家多多支持。 

-六神源码网