解决页面传递中文参数乱码问题

This commit is contained in:
xiongfeng
2022-07-05 18:03:35 +08:00
parent 7c45f81cf1
commit 20fd8827af
2 changed files with 4 additions and 3 deletions

View File

@@ -62,9 +62,9 @@
.then(function (response) {
var data = response.data;
if (data.code == 200) {
var param = "?token=" + data.data.token + "&name=" + data.data.name;
window.location.href = encodeURI("success.html" + param)
//中文需要进行两次encodeURI转码( encodeURI:把URI字符串采用UTF-8编码格式转化成escape格式的字符串)
var param = "?token=" + data.data.token + "&name=" + encodeURI(encodeURI(data.data.name));
window.location.href ="success.html" + param
} else {
alert(data.message)
}

View File

@@ -26,6 +26,7 @@
},
mounted: function () {
this.token = this.getData("token");
//只需要转一次码
this.name = decodeURI(this.getData("name"));
},
methods: {