[Vuejs]-How to display all selected users on click in vue

1πŸ‘

βœ…

To display the right format you probably want to map over selectedWorkers to select the keys you want (id and name), using string template syntax. Then use join to combine the result

alert(this.selectedWorkers.map(worker=>`${worker.id}-${worker.name}`).join())

Example of assumed format:

const selectedWorkers = [{
  id: 'AA',
  name: 'Lou Poole'
},{
  id: 'BB',
  name: 'Jonathan Fuller'
}]

alert(selectedWorkers.map(worker => `${worker.id}-${worker.name}`).join())
πŸ‘€depperm

Leave a comment