sh-webutils
v1.0.2
Published
前端工具包,包含上百种javascript工具,方便快捷,持续更新。。。
Downloads
6
Maintainers
Readme
sh-webutils
| 文档地址 | https://jiangsihan.gitee.io/front_end/webutils/webutils.html | | -------- | ---------------------------------------- | | 仓库地址 | https://gitee.com/jiangsihan/web-utils |
::: tip 前端 JavaScript 函数工具库
作者:ZiChen Jiang
最新版本:1.0.0
最近更新:2022-08-22
:::
简介
包含上百种
javascript
方法,检测邮箱、手机号码、字符串、数组、去重、AES/DES等.....持续更新中.....
下载
npm:
npm i sh-webutils
cnpm:
cnpm i sh-webutils
yarn:
yarn add sh-webutils
用法
import { API , API , API } from 'sh-webutils'
// API 为方法名,如:isEmail、isMobile等
API
1、检测是否为邮箱
import { isEmail } from 'sh-webutils'
isEmail('[email protected]') // true
isEmail('1111') //false
2、检测是否为手机号
import { isMobile } from 'sh-webutils'
isMobile('18307106535') //true
isMobile('1111') //false
3、检测是否为电话号码
import { isPhone } from 'sh-webutils'
isPhone('400-670-0700') //true
isPhone('400-670') //false
4、检测是否为url地址
import { isURL } from 'sh-webutils'
isURL('https://jiangsihan.cn') //true
isURL('https://jiangsihan') //false
5、是否字符串
import { isString } from 'sh-webutils'
isString('hhhh') //true
isString(123) //false
6、是否数值
import { isNumber } from 'sh-webutils'
isNumber(123) //true
isNumber('123') //false
7、是否boolean
import { isBoolean } from 'sh-webutils'
isBoolean(true) // true
isBoolean('123') // false
8、是否为null
import { isNull } from 'sh-webutils'
isNull(null) //true
isNull('123') //false
9、数组排序
import { sort } from 'sh-webutils'
// type: 1:从小到大 2:从大到小 3:随机
sort(array,type)
10、字符串去除空格
import { trim } from 'sh-webutils'
// type: 1-所有空格 2-前后空格 3-前空格 4-后空格
trim(str, type)
11、字符转换
import { changeCase } from 'sh-webutils'
// type: type: 1:首字母大写 2:首字母小写 3:大小写转换 4:全部大写 5:全部小写
changeCase(str, type)
12、将数字转换为大写金额
import { changeToChinese } from 'sh-webutils'
let num = 300
changeToChinese(num) // 三百元
13、将阿拉伯数字翻译成中文的大写数字
import { numberToChinese } from 'sh-webutils'
let num = 300
numberToChinese(num) // 三百