首页 分类列表
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
function deepClone(obj) {
|
||||
let result = typeof obj.splice === "function" ? [] : {};
|
||||
if (obj && typeof obj === 'object') {
|
||||
for (let key in obj) {
|
||||
if (obj[key] && typeof obj[key] === 'object') {
|
||||
result[key] = deepClone(obj[key]);//如果对象的属性值为object的时候,递归调用deepClone,即在吧某个值对象复制一份到新的对象的对应值中。
|
||||
} else {
|
||||
result[key] = obj[key];//如果对象的属性值不为object的时候,直接复制参数对象的每一个键值到新的对象对应的键值对中。
|
||||
}
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
export default deepClone
|
||||
@@ -0,0 +1,23 @@
|
||||
export default function(hexStr){
|
||||
//十六进制颜色值的正则表达式
|
||||
let reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
|
||||
let sColor = hexStr.toLowerCase();
|
||||
if (sColor && reg.test(sColor)) {
|
||||
if (sColor.length === 4) {
|
||||
let sColorNew = "#";
|
||||
for (let i = 1; i < 4; i += 1) {
|
||||
sColorNew += sColor.slice(i, i + 1).concat(sColor.slice(i, i + 1));
|
||||
}
|
||||
sColor = sColorNew;
|
||||
}
|
||||
//处理六位的颜色值f
|
||||
let sColorChange = [];
|
||||
for (let i = 1; i < 7; i += 2) {
|
||||
sColorChange.push(parseInt(`0x${sColor.slice(i, i + 2)}`));
|
||||
}
|
||||
let rgbText = sColorChange.join(",")
|
||||
return rgbText;
|
||||
} else {
|
||||
return sColor;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user