常用的数据拼接方法(不断更新中)
作者:互联网
trim(str) {
return str.replace(/(^\s*)|(\s*$)/g, "");
}
转换数据格式
convertField(record) {
return {
code: record.label,
name: record.label,
ord: record.key
}
}
// 转换数组
reverseFieldInArray(data) {
return data.map((record) => {
if (Object.keys(record).length == 0) {
return {}
} else {
return {
key: record.ord,
label: record.name
}
}
})
}
//对象数组去重
let hash = {};
btnValue = resetValue.reduce((preVal, curVal) => {
hash[curVal.ord] ? '' : hash[curVal.ord] = true && preVal.push(curVal);
return preVal
}, [])
标签:常用,return,不断更新,curVal,record,拼接,hash,ord,preVal 来源: https://www.cnblogs.com/snowhite/p/14446774.html