先在当前页面引入min.js
import jsencrypt from '@/utils/jsencrypt.min.js'
获取公钥的方法,在页面一加载就调用
getkey(){
this.show3=false;
var api='/auth/getKey';
var data={}
this.axios.post(api,Qs.stringify(data),{headers:{
'Content-Type':'application/x-www-form-urlencoded'
}}).then((response)=>{
console.log("返回:"+response)
if(response.status==200){
this.publickey = response.data.key;
}else{
return "error";
}
}).catch((error)=>{
this.show3=true;
this.fullscreenLoading = false;
console.log(error);
})
},
在登录方法里写
if(this.publicKey != null || this.publickey != ""){
var encrypt = new JSEncrypt();
encrypt.setPublicKey(this.p