How to add a unique identity to an indefinite array of objects

has an indefinite array

arr = [{a:"",b:"",c:""}] abc 

Click the add button to push an object in arr

arr = [{a:"",b:"",c:""},{a:"",b:"",c:""},{a:"",b:"",c:""}]

Click the delete button to delete the corresponding object

arr = [{a:"",b:"",c:""},{a:"",b:"",c:""}]


I want to add an id to each object when clicking add. This id is unique when the id is deleted. The id that has been added will not change at this time.
arr = [{br / p >]

Sep.01,2021

use a count variable

var i = 0
arr = []
arr.push({id:iPP})
arr.push({id:iPP})
arr.push({id:iPP})

use js to set a guid for each element of the array

function guid() {
  function s4() {
    return Math.floor((1 + Math.random()) * 0x10000)
      .toString(16)
      .substring(1);
  }
  return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
}

I understand what the downstairs owner means. Do you want to give a unique id, every time you add it to avoid deletion? If you want id to be the only one, it is a timestamp, and the timestamp will not be repeated


my idea is to determine a fixed id to distinguish which

this.$refs['check_cn'+item.id].resetFields();

doesn't seem to work.


this requires you to design binding verification rules through id when you start to do it, and then when you delete a form, there will be no verification confusion

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eb1784-235e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eb1784-235e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?