# sh-webutils

前端 JavaScript 函数工具库

作者:ZiChen Jiang

邮箱:18307106535@163.com

最新版本:1.0.0

最近更新:2022-08-22

# 简介

包含上百种javascript方法,检测邮箱、手机号码、字符串、数组、去重、AES/DES等.....

持续更新中.....

# 下载

npm:

npm i sh-webutils
1

cnpm:

cnpm i sh-webutils
1

yarn:

yarn add sh-webutils
1

# 用法

import { API , API , API } from 'sh-webutils'

//  API 为方法名,如:isEmail、isMobile等
1
2
3

# API

# 1、检测是否为邮箱

import { isEmail } from 'sh-webutils'

isEmail('18307106535@163.com')  // true
isEmail('1111')  //false
1
2
3
4

# 2、检测是否为手机号

import { isMobile } from 'sh-webutils'

isMobile('18307106535')  //true
isMobile('1111')  //false
1
2
3
4

# 3、检测是否为电话号码

import { isPhone } from 'sh-webutils'

isPhone('400-670-0700')  //true
isPhone('400-670')  //false
1
2
3
4

# 4、检测是否为url地址

import { isURL } from 'sh-webutils'

isURL('https://jiangsihan.cn')  //true
isURL('https://jiangsihan')  //false
1
2
3
4

# 5、是否字符串

import { isString } from 'sh-webutils'

isString('hhhh')  //true
isString(123)  //false
1
2
3
4

# 6、是否数值

import { isNumber } from 'sh-webutils'

isNumber(123)  //true
isNumber('123')  //false
1
2
3
4

# 7、是否boolean

import { isBoolean } from 'sh-webutils'

isBoolean(true)  // true
isBoolean('123')  // false
1
2
3
4

# 8、是否为null

import { isNull } from 'sh-webutils'

isNull(null) //true
isNull('123') //false
1
2
3
4

# 9、数组排序

import { sort } from 'sh-webutils'

// type: 1:从小到大 2:从大到小 3:随机
sort(array,type)
1
2
3
4

# 10、字符串去除空格

import { trim } from 'sh-webutils'

// type: 1-所有空格 2-前后空格 3-前空格 4-后空格
trim(str, type)	
1
2
3
4

# 11、字符转换

import { changeCase } from 'sh-webutils'

// type: type: 1:首字母大写 2:首字母小写 3:大小写转换 4:全部大写 5:全部小写
changeCase(str, type)	
1
2
3
4

# 12、将数字转换为大写金额

import { changeToChinese } from 'sh-webutils'

let num = 300
changeToChinese(num)	// 三百元
1
2
3
4

# 13、将阿拉伯数字翻译成中文的大写数字

import { numberToChinese } from 'sh-webutils'

let num = 300
numberToChinese(num)	// 三百
1
2
3
4

# 文档未更新完,请稍后......

Last Updated: 8/22/2022, 5:38:38 PM