izk-util
v1.1.5
Published
izk tools package. 提供一般通用方法集合,常用方法都可以往里放。
Downloads
6
Keywords
Readme
##izk-util
包下载: npm install izk-util@latest
api说明文档:
###getUrlParameter
获取URL中的参数 method: getUrlParameter params: String: 参数名, 例如: key String: 地址, 默认: 当前页面地址, 例如: http://www.izhikang.com/ return: String
... ###serializerToJson
将序列化字符串转为json
let izkUtil = require('izk-util');
let queryString = 'name=liujintao&age=28&address=beijing';
let queryObj = izkUtil.serializerToJson(queryString);
console.log(queryObj);
output
{ name: 'liujintao', age: '28', address: 'beijing' }
###jsonToSerializer
将json对象转为序列化字符串
let izkUtil = require('izk-util');
let queryObj = {name: 'liujintao', age: '28', address: 'beijing'};
let queryString = izkUtil.jsonToSerializer(queryObj);
console.log(queryString);
output
name=liujintao&age=28&address=beijing
###checkMobile
获取设备信息
var device = izkUtil.checkMobile();
console.log(device);
output
iphone
###cookie cookie相关操作
cookie.set 设置cookie
izkUtil.cookie.set('cookie_name','cookie value here','domain.com','/path/to/set/cookie','hours')
cookie.get 读取cookie
izkUtil.cookie.get('cookie_name')
cookie.del 删除cookie
izkUtil.cookie.del('cookie_name')
###formatDate
日期格式化, 返回格式化的字符串
let izkUtil = require('izk-util');
let now = new Date();
let dateString = izkUtil.formatDate(now,'yyyy年MM月dd日 hh:mm');
console.log(dateString);
###isSupportWebp
设备webp图片支持检测
let izkUtil = require('izk-util');
izkUtil.isSupportWebp(type=>{console.log(type)});
###imageMogr2
图片裁剪(适用于腾讯云)
let izkUtil = require('izk-util');
let imgurl = izkUtil.imageMogr2(imageOriginUrl,{w:180,h:160});
ES Module支持
import izkutil from 'izkutil/dist/izkutil.esm.min';
let queryObj = {name: 'liujintao', age: '28', address: 'beijing'};
let queryString = izkUtil.jsonToSerializer(queryObj);
console.log(queryString);