AI聊天prompt

创作📕 小红书爆款标题 生成引人入胜的小红书标题 123456789101112131415161718192021222324252627282930313233你是一名专业的小红书爆款标题专家,你熟练掌握以下技能:一、采用二极管标题法进行创作:1、基本原理:- 本能喜欢:最省力法则和及时享受- 生物本能驱动力:追求快乐和逃避痛苦 由此衍生出2个刺激:...

Read More

TypeScript全解:JS&TS

d.ts 文件的妙用默认情况下 *.d.ts 中的 type,interface 全局生效 12345// types.d.tstype User = { name: string; age: number;} 12// main.tstype A = User 但如果 *.d.ts 里有 import 或 export,则 Us...

Read More

React 泛型组件是什么?

案例假设我们要做一个很简单的 Show 组件,用法如下: 1234<Show content="hi" onClick={c => console.log(c)}/> Show 组件会展示 content,并在用户点击 content 时把 content 传给 onClick。 因此代码中...

Read More

TypeScript全解:类型体操(上)

体操就是做锻炼,给你的大脑做锻炼有没有什么实际的意义呢?我觉得没有,工作中用不到,只是为了锻炼而已 if elseJS: 12345if (A <= B) { return true} else { return false} TS: 123type A = 1type B = 1 | 2type Res...

Read More

TypeScript全解:类型体操(下)

上难度,直接看 github 上的项目https://github.com/type-challenges/type-challenges Pick123456789101112interface Todo { title: string description: string completed: boolean}type T...

Read More

TypeScript全解:class(下)

成员可见性 public 类外可见 private 类内可见 #var 真私有属性 protected 子类和自己可见 123456789101112131415161718192021222324252627282930313233343536373839404142434445// public class Person1 { public...

Read More

TypeScript全解:class(上)

为什么需要类呢? 外来人口多,迫切需要 class(以前是没有专门的前端的,都是其他方向转行来的) class 是保留字,迟早要实现 class 大部分人对原型的理解不够(因为大多数都语言是使用 class 来描述面向对象) 语法12345678910111213141516171819202122232425262728// 写法一class Po...

Read More

TypeScript全解:泛型编程(下)

开始逐渐体操化 先来看一些内置的 TS 工具 123456789type Person = { name: string; age: number; }type X1 = Readonly<Person>type X2 = Partial<Person>type X3 = Required<Person&...

Read More

TypeScript全解:泛型编程(上)

什么是泛型?泛,指多简单来说就是多种类型 只要你能看懂 JS 的函数,那么你就能看懂 TS 的泛型 JS: 12const fn = (a, b) => a + bconst result = fn(1,2) // 3 TS: 12type Fn<A, B> = A | Btype Result = Fn<string, num...

Read More

TypeScript全解:深入对象与函数(下)

函数重载(overload)什么是函数重载?简单来说就是同名的函数,这个概念是从 java 来的 我们来看这个需求,一个方法接受的参数有两种情况,可能是 number,可能是 string 如果用 TS 来实现,非常简单 12345class X { method(n: number | string) { /* ... */ ...

Read More