function _getProductType (arr, num, str) {
let type = ''
arr.forEach(val => {
if (num == val.code_val) { //eslint-disable-line
type = val.code_desc
} else if (num == '1000') { //eslint-disable-line
type = '总计'
}
})
return type + '' + (str || '')
}
export async function productType (num, str) {
let productTypes = []
function aaa () {
return getByCode(52).then(res => {
if (res.data.success) {
productTypes = res.data.data
return _getProductType(productTypes, num, str)
}
})
}
let b = await aaa()
return b
}
productType 是vue的一个过滤器,但是返回的是promise,但是template中的label属性只接受string类型。
请问该如何处理这种情况(axios也是promise的...)
filters
只能是个同步函数。