首先,创建一个base64.js const Base64 = { //加密 encode(str) { return btoa(encodeURICo
首先,创建一个base64.js
const Base64 = {
//加密
encode(str) {
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g,
function toSolidBytes(match, p1) {
return String.fromCharCode('0x' + p1);
}));
},
//解密
decode(str) {
// Going backwards: from bytestream, to percent-encoding, to original string.
return decodeURIComponent(atob(str).split('').map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
}
}
export default Base64
在main.js里面引用
使用页面:
this.$router.push({
path: "/user/Recommend",
query:{
info:this.$Base64.encode(XXXXX)//this.$Base64.encode(JSON.stringify(row))
}
});
接受参数页面:
let params = JSON.parse(this.$Base64.decode(this.$route.query.info))
到此这篇关于Vue 路由传参加密的文章就介绍到这了,更多相关Vue 路由传参加密内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!
--结束END--
本文标题: Vue 路由传参加密的示例代码
本文链接: https://www.lsjlt.com/news/174807.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-01-12
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0