数据生成器——唯一id的List数组
1.使用Array.form()制造自定义的唯一id数组,接受两个参数。
const createValue = (creater, length = 10) => Array.from({ length }, creater);
const createUser = (v, index) => {
return {
id: index,
name: `user-${index}`,
age: Math.round(Math.random() * 100),
};
};
const res = createValue(createUser, 100);
console.log(res);