这是我的 data.js。如果我将另一个用户添加到我的表中,我想将最后一个现有数据增加到加 1。我将以前生成的 id 中的 nanoid 用于我的 userRows 数据。但我希望我的 id 增加 1。例如,我创建的最后一个用户的 ID 为 20,我希望我的下一个用户是 21。有人可以帮助我或指导我修复生成的 id 吗?提前谢谢你。
export const userRows = [
{
id: 1,
username: "Richmond",
fullName: "Richmond Vicente Ramil",
img: "https://demos.themeselection.com/materio-mui-react-nextjs-admin-template/demo-1/images/avatars/3.png",
status: "active",
email: "Richmond@gmail.com",
age: 22,
},
{
id: 2,
username: "Fernand",
fullName: "Fernaan Million Galeron",
img: "https://demos.themeselection.com/materio-mui-react-nextjs-admin-template/demo-1/images/avatars/3.png",
status: "passive",
email: "Fernand@gmail.com",
age: 23,
},
{
id: 3,
username: "Jerson",
fullName: "Jerson Tablatin Aganon",
img: "https://demos.themeselection.com/materio-mui-react-nextjs-admin-template/demo-1/images/avatars/3.png",
status: "active",
email: "Jerson@gmail.com",
age: 23,
},
{
id: 4,
username: "Jyvonn",
fullName: "Jyvonn Nool Juan",
img: "https://demos.themeselection.com/materio-mui-react-nextjs-admin-template/demo-1/images/avatars/3.png",
status: "active",
email: "Jyvonn@gmail.com",
age: 24,
},
{
id: 5,
username: "Mike",
fullName: "Mike Tyson Kid",
img: "https://demos.themeselection.com/materio-mui-react-nextjs-admin-template/demo-1/images/avatars/3.png",
status: "pending",
email: "Mike@gmail.com",
age: 20,
},
{
id: 6,
username: "Mark",
fullName: "Mark Bryant Cleofas",
img: "https://demos.themeselection.com/materio-mui-react-nextjs-admin-template/demo-1/images/avatars/3.png",
status: "passive",
email: "Mark@gmail.com",
age: 26,
},
{
id: 7,
username: "Bryan",
fullName: "Bryan Brenna Tiofelo",
img: "https://demos.themeselection.com/materio-mui-react-nextjs-admin-template/demo-1/images/avatars/3.png",
status: "active",
email: "Bryan@gmail.com",
age: 32,
},
{
id: 8,
username: "Jonathan",
fullName: "Jonathan Nool Cleofas",
img: "https://demos.themeselection.com/materio-mui-react-nextjs-admin-template/demo-1/images/avatars/3.png",
status: "active",
email: "Jonathan@gmail.com",
age: 19,
},
{
id: 9,
username: "Walter",
fullName: "Walter Mike Mart",
img: "https://demos.themeselection.com/materio-mui-react-nextjs-admin-template/demo-1/images/avatars/3.png",
status: "pending",
email: "Walter@gmail.com",
age: 30,
},
{
id: 10,
username: "Vincent",
fullName: "Vincent Abdul Saudi",
img: "https://demos.themeselection.com/materio-mui-react-nextjs-admin-template/demo-1/images/avatars/3.png",
status: "pending",
email: "Vicent@gmail.com",
age: 42,
},
{
id: 11,
username: "Galeon",
fullName: "Galeon Mark Apollo",
img: "https://demos.themeselection.com/materio-mui-react-nextjs-admin-template/demo-1/images/avatars/3.png",
status: "active",
email: "Galeon@gmail.com",
age: 46,
},
{
id: 12,
username: "Brandon",
fullName: "Brandon Vicente Ramil",
img: "https://demos.themeselection.com/materio-mui-react-nextjs-admin-template/demo-1/images/avatars/3.png",
status: "passive",
email: "Brandon@gmail.com",
age: 25,
},
{
id: 13,
username: "Kenneth",
fullName: "Kenneth Timothy Sison",
img: "https://demos.themeselection.com/materio-mui-react-nextjs-admin-template/demo-1/images/avatars/3.png",
status: "passive",
email: "Keneth@gmail.com",
age: 26,
},
{
id: 14,
username: "Alexis",
fullName: "Alexis Delos Santos",
img: "https://demos.themeselection.com/materio-mui-react-nextjs-admin-template/demo-1/images/avatars/3.png",
status: "active",
email: "Alexis@gmail.com",
age: 22,
},
{
id: 15,
username: "John",
fullName: "John Kyle Abrera",
img: "https://demos.themeselection.com/materio-mui-react-nextjs-admin-template/demo-1/images/avatars/3.png",
status: "active",
email: "John@gmail.com",
age: 28,
},
{
id: 16,
username: "Patrick",
fullName: "Patrick Martin Nievera",
img: "https://demos.themeselection.com/materio-mui-react-nextjs-admin-template/demo-1/images/avatars/3.png",
status: "pending",
email: "Patrick@gmail.com",
age: 23,
},
{
id: 17,
username: "Steve",
fullName: "Steve Work Job",
img: "https://demos.themeselection.com/materio-mui-react-nextjs-admin-template/demo-1/images/avatars/3.png",
status: "active",
email: "Steve@gmail.com",
age: 24,
},
{
id: 18,
username: "Ralph",
fullName: "Ralph Dela Pena",
img: "https://demos.themeselection.com/materio-mui-react-nextjs-admin-template/demo-1/images/avatars/3.png",
status: "passive",
email: "Ralph@gmail.com",
age: 46,
},
{
id: 19,
username: "Chandler",
fullName: "Chandler Dark Mosquito",
img: "https://demos.themeselection.com/materio-mui-react-nextjs-admin-template/demo-1/images/avatars/3.png",
status: "active",
email: "Chandler@gmail.com",
age: 29,
},
{
id: 20,
username: "Reyster",
fullName: "Reyster John Car",
img: "https://demos.themeselection.com/materio-mui-react-nextjs-admin-template/demo-1/images/avatars/3.png",
status: "active",
email: "Reyster@gmail.com",
age: 29,
},
];
我想生成 ID。如果我添加一个新用户,下一个 id 将是 21
const newUser = {
//I want to put the next id which is 21 here on my newUser object and id property
//id: ID 21 here ,
username: addFormData.username,
img: file
? URL.createObjectURL(file)
: "https://yt3.ggpht.com/CblhnSj8-Q6Ptr6n8Nq1e3wB4gadeNM_IYjDma89iNfuTrAfsMwogvkPFb6JbG8XS-fdBnN5Plk=s88-c-k-c0x00ffffff-no-rj-mo",
fullName: addFormData.fullName,
email: addFormData.email,
age: addFormData.age,
status: addFormData.status,
};
© 版权声明
本站下载的源码均来自公开网络收集转发二次开发而来,
若侵犯了您的合法权益,请来信通知我们1413333033@qq.com,
我们会及时删除,给您带来的不便,我们深表歉意。
下载用户仅供学习交流,若使用商业用途,请购买正版授权,否则产生的一切后果将由下载用户自行承担,访问及下载者下载默认同意本站声明的免责申明,请合理使用切勿商用。
THE END
暂无评论内容