0.1.1 • Published 2 years ago

xbot-fe-utils v0.1.1

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

xybot-front-utils

影刀前端方法库

使用方法

npm intsall xybot-front-utils

setCookie

设置cookie

参数

  1. name(string): cookie的name值
  2. value (string) cookie的value值

返回

例子

  import { setCookie } from 'xybot-front-utils'
  setCookie(name, value)

getCookie

获取cookie

参数

  1. name(string): cookie的name值

返回

(sting):返回cookie值

例子

  import { getCookie } from 'xybot-front-utils'
  getCookie(name)

delCookie

删除cookie

参数

  1. name(string): cookie的name值

返回

例子

  import { delCookie } from 'xybot-front-utils'
  delCookie(name)

formatNumber

格式化时间 +0

参数

  1. number (string|number) 待处理时间

返回

(string | number): 返回处理之后的时间

例子

import { formatNumber } from 'xybot-front-utils'
formatNumber(9)
// => 09

formatNumber(10)
// => 10

formatDate

格式化时间 2022-01-01 12:12:12

参数

  1. timestamp (number) 待处理时间戳
  2. beforeSeparate (string) 年月日分隔符 默认 -
  3. afterSeparate (string) 时分秒分隔符 默认 :

返回

(string): 返回处理之后的时间

例子

import { formatDate } from 'xybot-front-utils'
formatDate(1641784747332)
// => 2022-01-10 11:19:07

getFormatTime

格式化时间 1641799837000 => 2分钟前

参数

  1. timestamp (number) 待处理时间戳

返回

(string): 返回处理之后的时间

例子

import { getFormatTime } from 'xybot-front-utils'
getFormatTime(1641784747332)
// => 2分钟前