函数: getUuid()
ts
function getUuid(): string;定义于: common.ts:141
生成一个标准的 UUID v4 字符串。
返回值
string
形如 xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx 的 36 位字符串
备注
优先使用原生 crypto.randomUUID(随机质量更好);环境不支持时回退为 基于 Math.random 的手动实现,仍遵循 v4 规则(version 位固定 4、variant 位取 8/9/a/b)。
示例
ts
getUuid() // => 'a1b2c3d4-5678-4abc-9def-0123456789ab'参见
- getRandomId 生成指定长度的随机 ID
- getUniqueId 生成进程内自增唯一 ID