首先看一下後端返回數據的格式:
這裏要取出數組裏面所有的user並進行去重操作。
代碼:
getAllUser()
.then((res) => {
const newArr = res.data.map(data => data.user);
this.userList = [...new Set(newArr)];
})
.catch(() => {});
首先看一下後端返回數據的格式:
這裏要取出數組裏面所有的user並進行去重操作。
代碼:
getAllUser()
.then((res) => {
const newArr = res.data.map(data => data.user);
this.userList = [...new Set(newArr)];
})
.catch(() => {});