Skip to content

Commit

Permalink
🎨 react typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
haibo.li committed Aug 12, 2020
1 parent 1a768f7 commit fd5ed98
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 12 deletions.
2 changes: 2 additions & 0 deletions about/version.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@
> 2019-08-01 添加 🆕 工具集合 收集一些常用的网站
> 2019-08-03 添加 🆕 工具浏览器 新加控制台对象复制功能
> 2019-08-12 添加 🆕 前端知识汇总 增加 typescript react 知识点
16 changes: 8 additions & 8 deletions advance/egg.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# egg

plugin
## plugin

service
## service

controller
## controller

public
## public

config
## config

schedule:计划任务
## schedule:计划任务

国际化
## i18n 国际化

i18n={
defaultLocal:'zh-CN'
}

扩展属性-
### 扩展属性-

npm i egg-scripts --save

Expand Down
6 changes: 6 additions & 0 deletions web/react.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ import {Consumer} from '../context.js';
1. useContext 接收一个 context 对象(React.createContext 的返回值)并返回该 context 的当前值
1. useLayoutEffect: useEffect 相同,但它会在所有的 DOM 变更之后同步调用 effect

## React v17.0

1. React 17 的版本是非比寻常的,因为它没有添加任何面向开发人员的新功能。而主要侧重于「升级简化 React 本身
1. 更改事件委托
1. 更改事件委托

## react-router4

1. 所有组件更改为从 react-router-dom 导入
Expand Down
29 changes: 25 additions & 4 deletions web/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,27 @@ any:任何类型
void:不需要返回值 function
```

## Record

1. ts 文档上对 Record 的介绍不多,但却经常用到,Record 是一个很好用的工具类型

```typescript
type person = {
prop1: string;
prop2: string;
prop3: string;
};
type someProps = Record<12 | keyof person, string>;
let newPerson: someProps = {
prop1: '111',
prop2: '222',
prop3: '444',
12: 'asdad'
};
```

```typescript
let a = 13; //默认number
let a; // any
Expand All @@ -33,9 +54,9 @@ let a: string | number = 12; //string number 都可以
let arr: number[] = [1, 2, 3]; //array 是number
let arr: any[] = ['svb', 12, false]; //any
let point: {x: number; y: number; z?: number};
point = {x: 12, y: 30};
point = {x: 12, y: 30, z: 99};
let point: { x: number; y: number; z?: number };
point = { x: 12, y: 30 };
point = { x: 12, y: 30, z: 99 };
```

### 外部引用第三方库
Expand Down Expand Up @@ -128,7 +149,7 @@ object: function get() {
}
let {
code: guname,
price: {price2}
price: { price2 }
} = get();
console.log(guname);
console.log(price2);
Expand Down

0 comments on commit fd5ed98

Please sign in to comment.