
js
117jf
这个作者很懒,什么都没留下…
展开
-
javaScript简介
通过浏览器内置的JavaScript引擎进行解释执行,把一个原本只用来显示的页面转变成支持用户交互的页面程序原创 2022-12-20 13:56:39 · 556 阅读 · 0 评论 -
使用jquery时,ajax统一添加头信息
使用jquery时,ajax统一添加头信息$(document).ajaxSend(function(event, jqxhr, settings) { jqxhr.setRequestHeader('token', token)})原创 2022-05-18 16:56:46 · 1415 阅读 · 0 评论 -
fastclick 解决移动端点击事件延迟300ms和点击穿透的问题
为什么移动端点击事件会有300ms延迟?首款 iPhone开发时遇到一个问题:当时的网站都是为大屏幕设备所设计的,而小屏幕浏览桌面端站点的缩放时如何系统判断?于是做出一个双击缩放(double tap to zoom)的约定,这也是会有上述 300 毫秒延迟的主要原因。双击缩放,顾名思义,即用手指在屏幕上快速点击两次,iOS 自带的 Safari 浏览器会将网页缩放至原始比例。 那么这和 300 毫秒延迟有什么联系呢?假定这么一个场景: 用户在 iOS Safari 里边点击了一个链接。由于用户可以进原创 2022-01-14 15:53:23 · 1822 阅读 · 0 评论 -
数组/数组对象 去重
数组let arr = [1, 2, 3, 3, 4, 4, 5]let newArr = Array.from(new Set(arr))console.log(newArr)对象let arr = [ { id: 1111, name: 'aaa' }, { id: 2222, name: 'bbb' }, { id: 1111, name: 'aaa' }, { id: 3333, name: 'ccc' } ]arr = arr.filter((s =>原创 2021-08-17 09:28:30 · 109 阅读 · 0 评论 -
数组对象线性和树形结构的转换
线性转树形jsonToTree = (arr) => { let map = {}; arr.forEach(v => { map[v.id] = v; }); let tree = []; arr.forEach(item => { const mapItem = map[item.pid]; if (mapItem) { (mapItem.children || (mapItem.children = [])).push(item); } else原创 2021-08-17 09:28:16 · 153 阅读 · 0 评论 -
sort 单条件&多条件排序
const list = [ {type: '2', isEnable: false,}, {type: '3', isEnable: true,}, {type: '1', isEnable: true,}, {type: '4', isEnable: false,}, {type: '0', isEnable: true,}]根据type升序list = list.sort((a, b) => a.type - b.type)首先isEnable为true排前面,然原创 2021-06-19 16:26:31 · 657 阅读 · 0 评论