数字千分位

num = 12345.45678 num.toLocaleString('en-US',{minimumFractionDigits:5}) minimumFractionDigits:保留小数几位

read more..

多级目录将数据递归成树状

let data = [ { id: 1, name: "电器", parentid: 0 }, { id: 2, name: "日用品", parentid: 0 }, { id: 3, name: "车用品", parentid: 0 }, { id: 4, name: "电饭煲", parentid: 1 }, { id: 5, name: "毛巾", parentid: 2 }, { id: 6, name: "雨刷器", parentid: 3 }, { id: 7, name: "小锅", parentid: 4 }, { id: 8, name: "绸缎毛巾", parentid: 5 }, { id: 9...

read more..

时间API

苏宁: https://f.m.suning.com/api/ct.do or http://quan.suning.com/getSysTime.do { "api": "time", "code": "1", "currentTime": 1647506518039, "msg": "" } or { "sysTime2": "2022-03-17 16:46:39", "sysTime1": "20220317164639" } 淘宝: http://api.m.taobao.com/rest/api3.do?api=mtop.common.getTimestamp { "api": "mtop.common.getTimestamp", "...

read more..

JS计算两个日期相差天数

function Start(startDateString, endDateString) { var startDate = Date.parse(startDateString); var endDate = Date.parse(endDateString); if (startDate > endDate) { return 0; } if (startDate == endDate) { return -1; //相等 } var days = (endDate - startDate) / (1 * 24 * 60 * 60 * 1000); return days; }

read more..

微信机器人PC

https://github.com/cixingguangming55555/wechat-bot 在PC端使用工具注入DLL,后台会启动一个WevSocket,实时发送消息.通过监听对呀的消息做处理

read more..

1900年至2100年公历、农历互转Js代码

/**公历年月日转农历数据 返回json**/ calendar.solar2lunar(2000,8,23); /**农历年月日转公历年月日**/ calendar.lunar2solar(2000,7,24); Animal: "龙" IDayCn: "廿四" IMonthCn: "七月" Term: "处暑" astro: "处女座" cDay: 23 cMonth: 8 cYear: 2000 gzDay: "癸丑" gzMonth: "甲申" gzYear: "庚辰" isLeap: false isTerm: true isToday: false lDay: 24 lMonth: 7 lYear: 2000 nWeek: 3 ncWeek: "...

read more..

NodeJs抓取页面

npm i cheerio request iconv-lite 思路:通过 request 获取到页面。在使用 iconv-lite 编译数据。在使用 cheerio 拿到对应的元素。这里以抓取微博热搜为例 const cheerio = require('cheerio'); const request = require('request'); const iconv = require('iconv-lite'); function http(url, decode = 'utf8') { return new Promise((resolve, rejext) => { request({ url, encoding...

read more..

随机数

function getRandom(start, end, fixed = 0) { let differ = end - start let random = Math.random() return (start + differ * random).toFixed(fixed) } getRandom(1,5) 1<= num >=5

read more..