使用方法如下
this.$utils.pub.getResult(this.getResult, 1, 'key', 'value')
封装如下
util.getResult = function (arr = [], id = '', find = 'id', result = 'value') {
let value = ''
if (id === undefined || id === null || !find || !result) {
return ''
}
arr.map(function (e) {
if (e[find] === id) {
value = e[result]
}
})
return value
}