每日一文

检测所有类型/一行css适配rem

2020-12-17  本文已影响0人  永恒即是最美

检测所有类型:

/**
 * 检测类型
 * @param {any} target 检测的目标
 * @returns {"string"|"number"|"array"|"object"|"function"|"null"|"undefined"} 只枚举一些常用的类型
 */  
function checkType(target) {  
  /** @type {string} */  
  const value = Object.prototype.toString.call(target);  
  const result = value.match(/\[object (\S*)\]/)[1];  
  return result.toLocaleLowerCase();  
}  

一行css适配rem(以前还引入js去计算,也是醉了)


html{ font-size: calc(100vw / 750); }

上一篇 下一篇

猜你喜欢

热点阅读