wo-tang

常用util封装

Usage no npm install needed!

<script type="module">
  import woTang from 'https://cdn.skypack.dev/wo-tang';
</script>

README

唐:wo-tang

一款精简的小插件集群
说明: 支持 CommonJS,便于 browserify, webpack 等直接使用

安装:

npm i wo-tang -S  

使用:

var tang = require('wo-tang');  

或者:

import tang from 'wo-tang';   

方法

1、响应式rem计算 说明:可以传入设计图宽度,默认为750px,则换算后,7.5rem 等于 100vw

tang.setRem(750)

2、截取Url参数

const param = tang.getUrlParam('chl')

3、防抖动函数

tang.debounce(func, delay)

4、格式化时间

const time = tang.formatTime(2)
// '02'

5、获取cookie字符串

const cookieVal = tang.getCookie('cookiename')

6、检测是否是手机号码

const result = tang.checkMobile(13657731130)
// true

7、 获取storege存储,时间限制。key为字符串,time为number,单位为s,默认时间为一天 60 * 60 * 24 * 1000s

const val = tang.getStorage(key, time)

8、 设置storege存储,时间限制。key为字符串。和getStorage搭配使用

tang.setStorege(key, val)