You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
11 lines
300 B
11 lines
300 B
/**
|
|
* @description: 数组item查询
|
|
* @param {Array} list
|
|
* @param {String} key
|
|
* @param {*} value
|
|
*/
|
|
export default function arrayFind(list = [], key, value, attr) {
|
|
const item = list.find(item => item[key] == value);
|
|
if (typeof attr !== 'undefined') return item?.[attr];
|
|
return item;
|
|
}
|
|
|