普通视图

发现新文章,点击刷新页面。
昨天以前时间的朋友

typescript 装饰器

2023年8月21日 22:06
typescript 装饰器 🔗 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 declare type MethodDecorator = <T>( target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T> ) => TypedPropertyDescriptor<T> | void type VoidFn = ((...args: any[]) => void) | ((...args: any[]) => Promise<void>) export const Performance =

WSL2问题解决WslRegisterDistribution failed with error: 0x800701bc

2023年8月14日 16:39
WSL2问题解决WslRegisterDistribution failed with error: 0x800701bc 🔗 开启 1 Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux 安装最新的wsl2 linux 内核 https://learn.microsoft.com/zh-cn/windows/wsl/install-manual#step-4—download-the-linux-kernel-update-package

请求中获取浏览器推荐语言

2023年7月27日 09:39
请求中获取浏览器推荐语言 🔗 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]

flutter 生命周期

2023年7月7日 20:54
flutter 生命周期 🔗 createState(): When the Framework is instructed to build a StatefulWidget, it immediately calls createState() mounted is true: When createState creates your state class, a buildContext is assigned to that state. buildContext is, overly simplified, the place in the widget tree in which this widget is placed. Here’s a longer explanation. All widgets have a bool this.mounted property. It is turned true when the buildContext

堆和栈

2023年6月22日 08:39
堆和栈 🔗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();

简易的事件监听EventBus

2023年6月17日 09:39
简易的事件监听 🔗 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];

forwardRef 定义的组件添加静态属性

2023年6月6日 07:00
forwardRef 定义的组件添加静态属性 🔗 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 import React, { ReactNode, RefAttributes, ForwardRefExoticComponent } from 'react'; interface ModalProps { title: ReactNode; } interface ModalStaticProps { show(): void; hide(): void; } const STATIC_PROPS:

js 获取滚动元素

2023年6月3日 20:25
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
❌
❌