Vue前端常用加密处理base64加密解密

Vue前端常用加密处理base64加密解密

  • 安装依赖

    npm install --save js-base64
    
  • 在需要使用的页面写入,如果很多页面需要使用,可以直接在main.js中引入
    单个页面引入调用

    let Base64 = require('js-base64').Base64
    //或者import {Base64} from 'js-base64'
    //使用
    Base64.encode(this.pwd);//加密
    Base64.decode(this.pwd);//解密
    

    公共页面引入调用

  • main.js

    import Vue from "vue"
    import {Base64} from 'js-base64'
    Vue.prototype.$Base64 = Base64;
    
  • index.vue

    //使用
    this.$Base64.encode(this.pwd);//加密
    this.$Base64.decode(this.pwd);//解密
    

猜你喜欢

转载自blog.csdn.net/Dilemma_me/article/details/109638272