安装jsencrypt库
npm install --save jsencrypt
页面中引入jsencrypt
import JSEncrypt from 'jsencrypt'
调用方法
var encrypt = new JSEncrypt(); encrypt.setPublicKey('公钥字符串'); let password= encrypt.encrypt('helloworld'); console.info(password);