前端生成uid
port.js:
export function getUUID () {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
return (c === 'x' ? (Math.random() * 16 | 0) : ('r&0x3' | '0x8')).toString(16)
})
}
//页面引入
import {getUUID} from "@/api/port";
查看获取uid:
mounted () {
let uid = getUUID()
//this.loginForm.uuid = getUUID();
console.log(uid) // 1ca0865b-7ea8-45f1-8b46-378fd497a5e6
},
还没有评论,来说两句吧...