This.departmentdata is the data from Figure 1 (Page)

Figure 2 is a dropdown selector of Ele. me. The need is to select a certain item (department) to get the name and ID of the selected department

The method provided by Ele. me can only get the ID or name, not both values.

Solutions:

Use the array filter method:

Write it in the change event in the dropdown selector

handleDepartment(val) { let arr = []; arr = this.departmentData.filter(item => item.name === val); this.addForm.deptId = arr[0].id; }