一、获取当前时间
getTime:function(){
var _this = this;
let yy = new Date().getFullYear();
let mm = new Date().getMonth()+1;
let dd = new Date().getDate();
let hh = new Date().getHours();
let mf = new Date().getMinutes()<10 ? '0'+new Date().getMinutes() : new Date().getMinutes();
let ss = new Date().getSeconds()<10 ? '0'+new Date().getSeconds() : new Date().getSeconds();
return yy+'/'+mm+'/'+dd+' '+hh+':'+mf;
},
二、定时任务的使用
methods: {
waiting(){
let txt=["请稍后","请稍后.","请稍后..","请稍后...","请稍后...."]
this.waitingtext=txt[id]
id=(id+1)%5
},
}
mounted(){
this.timer = setInterval(this.waiting, 400);
this.getFuck();
}
三、AES加密解密:CryptoJS+hutool
前端Vue代码Api:
const key = CryptoJS.enc.Utf8.parse("ABCDABCDABCDABCD"); //十六位十六进制数作为密钥
const iv = CryptoJS.enc.Utf8.parse('0102030405060708'); //十六位十六进制数作为密钥偏移量
export function jiemi(word){
let encryptedHexStr = CryptoJS.enc.Hex.parse(word);
let srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr);
let decrypt = CryptoJS.AES.decrypt(srcs, key, { iv: iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 });
let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);//解码roleId
return decryptedStr;
}
export function jiami(word){
let srcs = CryptoJS.enc.Utf8.parse(word);
let encrypted = CryptoJS.AES.encrypt(srcs, key, { iv: iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 });
var dd=encrypted.ciphertext.toString().toUpperCase();
return dd;
}
后端springboot:
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>4.5.13</version>
</dependency>
AES aes = new AES(Mode.CBC, Padding.PKCS5Padding, "ABCDABCDABCDABCD".getBytes(), "0102030405060708".getBytes());
//解密
String decrypt = aes.decryptStr(word);
//加密:
String encryptHex = aes.encryptHex(decrypt).toUpperCase();
四、Vue双击事件
<div id="123" v-on:dblclick="f1"></div>
methods:{
f1(){
console.log("gogogo")
}
}
五、字符串全局替换@@-><br/>+elpopover换行
getHuanhang(str){
str=str+''
str=str.replace(/@@/g,'<br/>')//正则,/g表示全局匹配
return str
},
<el-popover placement="bottom" width="300" trigger="hover">
<div v-html="getHuanhang(xxx.feeDesc)"></div>
<span slot="reference">{{ xxx.feeDesc==null?"":xxx.feeDesc.substr(0,20)+'...' }}</span>
</el-popover>