// 字典转义(转义、翻译) export function dictionaryEscape(dictionary = [], val = '', option = {}) { if (!(Array.isArray(dictionary) && dictionary.length)) return '' option = { valueKey: 'value', labelKey: 'name', dictionaryType: true,// true 为转义 false 为翻译 ...option } const {valueKey, labelKey, dictionaryType} = option let item = dictionary.find(i => i[dictionaryType ? valueKey : labelKey] === val) || {} return item[dictionaryType ? labelKey : valueKey] || '' }