[Vuejs]-How to detect vue data passed to vuex state and check for it

0👍

Simply you can make a function to check if selected music with id already in list.

isAlreadyAdded(id, arr) {
  let is_in = false;
  for (let i = 0; i < arr.length; i++) {
    if (arr[i].id === id) {
       is_in = true;
       break;
    }
  }
  return is_in;
}

Leave a comment