VUE 前端生成唯一标识 (guid)
utils/utils.js 文件const S4 = function() {return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);};export function guid() {return (S4() + S4() +'-' +S4() +'-' +S4() +'-' +S4() +'-' +S4()
·
utils/utils.js 文件
const S4 = function() {
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
};
export function guid() {
return (S4() + S4() +'-' +S4() +'-' +S4() +'-' +S4() +'-' +S4() +S4() +S4()
);
}
import { guid } from '@/utils/utils';
created() {
console.log(this.guid()); //679f0f92-e821-bbea-7536-8b4bb830f96d
},
methods: {
guid ,
}
更多推荐
已为社区贡献6条内容
所有评论(0)