1.安装
npm install --save js-base64
2.使用
方法1
let Base = require("js-base64").Base64;
this.cen = Base.encode(this.cen);
console.log(this.cen);
方法2
在mian.js中进行引入,挂在在Vue的原型对象上
import {Base64} from 'js-base64'
Vue.prototype.$Base64 = Base64;
let basedata = "bello";
let jiami = this.$Base64.encode(basedata); //加密
console.log(jiami);
let jiemi = this.$Base64.decode(jiami); //解密
console.log(jiemi);