- 博客(13)
- 收藏
- 关注
原创 数组相邻之间两个数相减
let indexArr = [10,8,65,74,56,23] let endIndexArr = indexArr.map(function (v: any, i: any, arr: any) { return v - ((i === 0) ? 0 : arr[i - 1]) }).slice(1) // console.log(endIndexArr,'endIndexArr'); [-2, 57, 9, -18, -33] "endIndexArr"
2021-05-18 15:02:35
1709
原创 降频
// 降频export const downConversion = (time = 100) => { clearTimeout(downConversion.timer); return new Promise((resolve, reject) => { downConversion.timer = setTimeout(resolve, time) }).catch(_ => {})}
2021-05-11 11:09:45
227
原创 一维数组拆分多个二位小数组
// 将一维数组拆分成多个二维小数组export const arraySplit = (arr, length) => { var result = []; for (var i = 0; i < arr.length; i += length) { result.push(arr.slice(i, i + length)); } return result;}
2021-05-11 11:08:25
150
原创 js 时间十位补零 (不满10补零)
fixNum (number, digits = 2) => { number = String(number); var length = number.length; if (number.length < digits) { for (var i = 0; i < digits - length; i++) { number = "0" + number; } } return number;}fixNum(1) // 01
2021-05-11 11:06:22
1030
原创 canvs 画分享海报
class Share { constructor(options = {} as any) { (<any>this).picArr = []; } public createPic() { let _this: any = this; if (!_this.sharepic) { _this.sharepic = document.createElement('div');
2021-05-11 10:18:13
135
原创 js获取本地IP地址
js获取本地IP地址/** * 获取本地ip地址 * @return {String} IP地址 */function getIPAdress() { let interfaces = require('os').networkInterfaces(); for (var devName in interfaces) { var iface = interfaces[devName]; for (var i = 0; i < iface.le
2021-04-30 12:14:52
917
转载 js每十个字符换行
// 字符串插入换行符\n getNewline(val) { let str = new String(val); let bytesCount = 0; let s = ""; for (let i = 0, n = str.length; i < n; i++) { let c = str.charCodeAt(i); ...
2021-04-15 14:20:31
1240
原创 工具类 提取富文本文字
/* 移除HTML标签代码 *//* eslint-disable */function removeHTMLTag (str) { str = str.replace(/<\/?[^>]*>/g, '') // 去除HTML tag str = str.replace(/[ | ]*\n/g, '\n') // 去除行尾空白 // str = str.replace(/\n[\s| | ]*\r/g,'\n'); //去除多余空行 str = str.replace(
2021-03-26 16:52:54
138
原创 url路径参数转换为对象方法
let url = ' https://m.baidu.com/s?word=%23vivoS9%23&topic_id=161395695626718677&sa=topicamis&sfrom=1023524a'; let json:any = {}; let parms = url.split('?')[1].split('&'); parms.forEach((item: any, index: number) => { ...
2021-03-26 15:57:27
497
原创 图片预加载
loadImageList(arr: string[], callback: any) { const p: any = (url: string) => { return new Promise((resolve, reject) => { let img = new Image(); img.src = url; ...
2021-03-16 18:55:16
96
原创 图片左右旋转及左右切换
pc电商图片旋转及切换 <div class="media-group" node-type="media_group_prev_2025718"> <ul class="clearfix"> <li class="bigVideo on" data-url="http://zol.iqiyi.com.cn/pl
2021-01-29 18:41:12
1129
原创 保留一位小数(四舍五入)
function decimal(num, v) { let vv = Math.pow(10, v); console.log(vv); return Math.round(num * vv) / vv; }
2021-01-29 18:40:25
1190
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人