数据生成器——唯一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);
posted @ 2022-08-05 11:53  SKa-M  阅读(52)  评论(0编辑  收藏  举报