2.0.5 • Published 9 months ago

format-function v2.0.5

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

URL

import {getRouterQuery,query,setUrl} from "format-function";

getRouterQuery()				获取URL上的参数,哈希和历史路由都适用
query							是getRouterQuery的返回值
openNewPage(url)				打开一个新的窗口

setUrl(url,query,is_cover)		
	设置url,url为一个完整的url,可包含参数,query为一个对象,is_cover为一个布尔值,当url上的参数query有相同时,query是否覆盖url的参数值,默认值为true,覆盖

localStorage

主要是简化设置storage

import {store} from "format-function";
store.set(name,value)
store.get(name)
store.remove(name)
store.clearAll()

object

array

执行后将会在数组的原型链上追加两个方法,分别是delete、insert,unique,uniqueObject方法。delete(index),index为要删除的索引。insert(index,arr),index为要插入的位置,arr为数组,存放插入的元素。unique方法只是简单的数组去重,使用Array.from(new Set(this))实现。uniqueObject(prop)方法,数组对象去重,prop为根据对象的字段去重

import {array} from "format-function";
array()

string

import {strStart,strEnd} from "format-function";

strStart(string,start)		判断字符串是否以特定开头,返回一个布尔值
strEnd(string,start)		判断字符串是否以特定结尾,返回一个布尔值

object

import {getObjectKey,getObjectValue,getObjectParse,getObjectString,deepClone} from "format-function";

getObjectKey(object)		获取对象的属性,返回值为一个数组
getObjectValue(object)		获取对象的属性值,返回值为一个数组
getObjectParse(object)		转换成json对象,返回值为json对象
getObjectString(object)		转换成json字符串,返回值为json字符串

deepClone(origin,target)	深拷贝,origin为原对象,target为目标对象,返回一个对象

DOM

CSS

import {
   setSingleEleCss,
   setAllEleCss,
   getSingleEleCss,
   getEleAllCss
} from "format-function";

setSingleEleCss(ele,style)
	设置单个元素的css样式,ele为要操作的单个dom元素,style为样式对象,例如{width:"50px"},无返回值
    
setAllEleCss(ele,style)
	设置多个元素的css样式,ele为要操作的dom元素集合,style为样式对象,例如{width:"50px"},无返回值

getSingleEleCss(selector,field)
	selector为css选择器,field为要获取的字段的值

getEleAllCss(selector)
	selector为css选择器,获取css全部的样式

DOM

import {
   getSingleEle,
   getAllEle
} from "format-function";

getSingleEle(selector)		获取单个dom元素,selector为css选择器,返回值为一个dom元素
getAllEle(selector)			获取dom元素集合,selector为css选择器,,返回值为一个dom元素集合

偏移量

import {
   getEleScrollTop,
   getPageScrollHeight,
   getIsTouchBottom,
   getEleClientWidth,
   getEleClientHeight,
   getEleOffsetTop,
   getEleOffsetParent,
   getEleOffsetHeight,
   getEleOffsetWidth,
   setEleScrollTop
} from "format-function";

getEleScrollTop()				获取页面滚动条的滚动距离,返回值为滚动距离
getPageScrollHeight()			获取窗口实际高度,返回值为窗口实际高度
getIsTouchBottom(ele,distance)	判断滚动是否触底,ele为要操作的单个dom元素,distance距离底部多少触发,返回值为一个布尔值
getEleClientWidth(selector)		获取元素的clientWidth
getEleClientHeight(selector)	获取元素的clientHeight
getEleOffsetTop(selector)		获取元素的offsetTop
getEleOffsetParent(selector)	获取元素的offsetParent
getEleOffsetHeight(selector)	获取元素的OffsetHeight
getEleOffsetWidth(selector)		获取元素的OffsetWidth
setEleScrollTop(selector,top)	top为距离

复制文本

import { copyText } from "format-function";
copyText(text,success,error)	复制文本,text为要复制的文本内容,success,error为回调函数

imgToBase64

import { imgToBase64 } from "format-function";
imgToBase64(file)	img图片文件转化base64,返回值为base64数值

downloadBlob

import { downloadBlob } from "format-function";
downloadBlob(blob,filename,success)				
2.0.5

9 months ago

2.0.3

2 years ago

2.0.4

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.39

2 years ago

1.0.38

2 years ago

1.0.40

2 years ago

1.0.43

2 years ago

1.0.41

2 years ago

1.0.37

2 years ago

1.0.36

2 years ago

1.0.35

2 years ago

1.0.34

2 years ago

1.0.26

2 years ago

1.0.29

2 years ago

1.0.28

2 years ago

1.0.27

2 years ago

1.0.33

2 years ago

1.0.32

2 years ago

1.0.31

2 years ago

1.0.30

2 years ago

1.0.25

3 years ago

1.0.22

3 years ago

1.0.21

3 years ago

1.0.24

3 years ago

1.0.23

3 years ago

1.0.20

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.9

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.0

3 years ago