react 常用方法整理

import React from 'react'

const utils = {
  isObject: params => Object.prototype.toString.call(params) === '[object Object]',
  isArray: params => Object.prototype.toString.call(params) === '[object Array]',
  isFunction: params => Object.prototype.toString.call(params) === '[object Function]',
  toSizeText: size => {
    let num = 0
    let unit = ''
    if (size / 1024 < 1000) {
      num = size / 1024
      unit = 'KB'
    } else if (size / 1024 / 1024 < 1000) {
      num = size / 1024 / 1024
      unit = 'MB'
    } else {
      num = size / 1024 / 1024 / 1024
      unit = 'GB'
    }
    num = Math.floor(num * 100) / 100
    return `${num}${unit}`
  },
  // 获取localStorage的已存容量
  getLocalSurplus: () => {
    if (!window.localStorage) {
      console.log('浏览器不支持localStorage');
  
上一篇:echarts隔柱换色


下一篇:Echarts立体地图加3D柱图可点击可高亮选中的开发