1.0.1 • Published 1 year ago

zz-functools v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

js 常用工具函数集合

一些没啥用的 js 函数,持续更新。。。

介绍

  1. 发送 AJAX 请求:ajax(url, method='GET', data='', headers={})
  2. 读写 cookie:cookie(key, value, expires='Session')
  3. 格式化时间:format_datetime(time='', str='datetime')
  4. 不刷新页面修改 url:replace_url(key, value)
  5. 根据 ua 判断设配类型:browser_type(type=/^\d+$/)
  6. 获取 url 上的参数:get_url_param(key, url=location.href)

安装

npm install zz-functools --save

使用

import * as tool from 'zz-functools'
import { browser_type } from 'zz-functools'

console.log(tool.browser_type(), browser_type())

更新记录

1.0.1 - 2022-11-25

更新 format_datetime 函数

由于 new Date() 在 IOS 系统中不支持 '2022-11-25 12:12:12' 格式,因此做了兼容处理

在 ios 和 windows 均验证通过

alert(tools.format_datetime('Fri Nov 25 2022 14:54:58 GMT+0800 (中国标准时间)'))  // new Date().toString()
alert(tools.format_datetime('2022-11-25 12:12:12'))  // format
alert(tools.format_datetime('2022-11-25T06:52:17.041Z'))  // new Date().toJSON()
alert(tools.format_datetime(1669359195535))  // new Date().getTime()