1. 使用插件
安装:npm i uuid
使用:
import {v4 as uuidV4} from 'uuid';
console.log(uuidV4()); // 随机数
2. 不使用插件
function randomId() {
return Math.random().toString(16).splice(2, 14);
}
1. 使用插件
安装:npm i uuid
使用:
import {v4 as uuidV4} from 'uuid';
console.log(uuidV4()); // 随机数
2. 不使用插件
function randomId() {
return Math.random().toString(16).splice(2, 14);
}