SharedArrayBuffer is not defined
SharedArrayBuffer is not defined 如何解决 🔗SharedArrayBuffer 是一种 JavaScript 对象,用于在多线程环境中共享内存。然而,由于共享内存的特性,它可能导致安全漏洞。
共找到 25 篇文章
SharedArrayBuffer is not defined 如何解决 🔗SharedArrayBuffer 是一种 JavaScript 对象,用于在多线程环境中共享内存。然而,由于共享内存的特性,它可能导致安全漏洞。
请求中获取浏览器推荐语言 🔗 1 2 3 4 5 6 7 8 9 10 11 12 let languages: string[] | undefined // get locale from cookie const localeCookie = request.cookies.get('locale') languages = localeCookie?.value ? [localeCookie.value] : [] if (!languages.length) { // Negotiator expects plain object so we need to transform headers const negotiatorHeaders: Record<string, string> = {} request.headers.forEach((value, key) => (negotiatorHeaders[key]
堆和栈 🔗Queue 🔗 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 import LinkedList from "./LinkedList"; class Queue { constructor() { this.linkedList = new LinkedList(); } isEmpty() { return !this.linkedList.head; } peek() { if (this.isEmpty()) return null; return this.linkedList.head.value; } enqueue(value) { this.linkedList.prepend(value); } dequeue() { return this.linkedList.deleteHead();
简易的事件监听 🔗 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 const createEvent = () => ({ events: {} as any, on(eventName: string, callback: Function) { this.events[eventName]?.push(callback) || (this.events[eventName] = [callback]); return () => { this.events[eventName] = this.events[eventName].filter( (e: any) => e !== callback ); }; }, emit(eventName: string, ...args: any[]) { const callbacks = this.events[eventName];
js 获取滚动父元素 🔗 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 const isScrollable = function (ele) { const hasScrollableContent = ele.scrollHeight > ele.clientHeight; const overflowYStyle = window.getComputedStyle(ele).overflowY; const isOverflowHidden = overflowYStyle.indexOf('hidden') !== -1; return hasScrollableContent && !isOverflowHidden; }; const getScrollableParent = function (ele) { return !ele || ele === document.body ? document.body : isScrollable(ele) ? ele
canvas requestAnimationFrame 画一个 clock 🔗 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 var requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame; var h1 = document.getElementsByTagName("h1")[0]; var canvas = document.getElementById("canvas"); var ctx
mousedown event中保持input的focus状态 🔗一定要使用e.preventDefault去除默认失去焦点行为 1 2 3 <input> <button>CLICK</button> <button>MOUSEUP</button> <button>MOUSEDOWN</button> <button>MOUSEDOWN 2</button> 1 2 3 4 5 6 7
比较两个数组的不同项 🔗如何比较两个数组的不同项,并且取出组成一个新的数组 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 function diffArray(one, two) { if
async await 🔗错误捕获 🔗async 函数永远返回一个promise 如果没有指定返回值,则默认返回一个resolve promise, 相当于return Promise.resolve() 如果返回一个值
1 2 3 4 5 6 7 8 9 10 11 12 13 14 $ npm install lerna -g $ mkdir lerna-demo $ cd lerna-demo && lerna init --independent # 用的默认的固定模式,vue babel等都是这个 $ cd packages $ mkdir moduleA && mkdir moduleB ... #分别进入三个
classnames库是日常工作中用来操作dom中class相关的工具函数,这里我们对它进行解读 使用 npm install classnames –save 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
toNumber 🔗lodash中转数字函数 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
1 2 3 4 5 6 7 8 9 10 11 function plus(num1, num2) { const num1Digits = (num1.toString().split('.')[1] || '').length; const num2Digits = (num2.toString().split('.')[1] || '').length; const baseNumber = Math.pow(10, Math.max(num1Digits, num2Digits)); return (num1 * baseNumber + num2 * baseNumber) / baseNumber; } function minus(num1, num2) { return plus(num1, -1 * num2); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 function isElement(obj: any) { try { // Using W3 DOM2 (works for FF, Opera and Chrome) return obj instanceof HTMLElement; } catch (e) { // Browsers not supporting W3 DOM2 don't have HTMLElement and // an exception is thrown and we end up here. Testing some // properties that all elements have (works on
操作相关classname工具函数 1 2 3 4 5 6 7 8 9 10 11 // 增加目标class function addClass(target = '', srcCls = '') { const clss = target.split(/\s+/) return [...clss.filter(cls => !clss.includes(cls)), srcCls] } function removeClass(target = '', srcCls = '') { const clss = target.split(/\s+/) return [...clss.filter(cls
日常我们在vue开发的时候使用公共事件总线进行跨组建数据传递,这里我们自己封装一个事件总线,了解其背后的原理 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
webpack Loaders and Plugins different 🔗Loaders: 🔗Loaders work at the individual file level during or before the bundle is generated. loader是文件加载器,能够加载资源文件,并对这些文件进行一些处理,
Element.append 🔗方法在 Element的最后一个子节点之后插入一组 Node 对象或 DOMString 对象。 被插入的 DOMString 对象等价为 Text 节点。 Element.append((Node or DOMString)… nodes); 示例代码 1 2 3 4 5 6 7 8 9 10 11 12 13 14
小程序中监听data中数据变量的变化 🔗 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 // 监听页面数据变化 export const PageWatch = (_page)
baseFindIndex 🔗查找数组中的索引 1 2 3 4 5 6 7 8 9 10 11 function baseFindIndex(array, predicate, fromIndex, fromRight) { const { length } = array let index = fromIndex + (fromRight ? 1 : -1) while ((fromRight ? index-- : ++index < length)) { if (predicate(array[index], index, array)) { return index } } return -1 }
没有找到相关文章
尝试调整搜索条件或查看其他标签