首先,创建一个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里面引用
import Base64 from './assets/js/base64.js' Vue.prototype.$Base64 = Base64;
使用页面:
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,return,Base64,js,str,encode,参加,路由 From: https://www.cnblogs.com/ZYSZBD/p/16976551.html