Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
onresize committed Apr 5, 2024
1 parent 0047073 commit feaaf1e
Show file tree
Hide file tree
Showing 9 changed files with 347 additions and 198 deletions.
2 changes: 1 addition & 1 deletion docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,6 @@ export default defineUserConfig({
searchPlugin({
// 排除首页
isSearchable: (page) => page.path !== '/',
}),
})
],
})
3 changes: 3 additions & 0 deletions docs/.vuepress/config/silder.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export default [
'/技术总结/踩坑总结/一个项目安装不同版本的依赖包',
'/技术总结/踩坑总结/MIME类型',
'/技术总结/踩坑总结/React.Fragment和空标签的区别',
'/技术总结/踩坑总结/React常用的内置hooks',
'/技术总结/踩坑总结/vite搭建react项目样式隔离方案',
'/技术总结/踩坑总结/TS入门到进阶',
'/技术总结/踩坑总结/项目生成md目录树',
'/技术总结/踩坑总结/CICD相关',
Expand Down Expand Up @@ -34,6 +36,7 @@ export default [
'/技术总结/踩坑总结/css常用单位',
'/技术总结/踩坑总结/uniapp写APP整包升级更新',
'/技术总结/踩坑总结/uniapp写APP消息推送方案',
'/技术总结/踩坑总结/高频面试题',
],
},
{
Expand Down
Binary file added docs/.vuepress/public/AA_mdPics/css_module.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion docs/.vuepress/styles/index.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
:root {
scroll-behavior: smooth;
--content-width: 930px;
}

.AnLi {
Expand Down Expand Up @@ -27,7 +28,7 @@ pre::-webkit-scrollbar {
}

::selection {
background: #807DD4;
background: #807dd4;
}

img {
Expand Down
29 changes: 29 additions & 0 deletions docs/技术总结/踩坑总结/React常用的内置hooks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: React常用的内置hooks
lang: zh-CN
feed:
enable: true
description: React常用的内置hooks
---

# React常用的内置hooks

> 本文作者:[onresize](https://github.com/onresize)
[更多参考官方文档](https://zh-hans.react.dev/reference/react/hooks)

### useState
### useEffect
### useContext
### useReducer

### useCallback
### useMemo

### useImperativeHandle

### useLayoutEffect
### useDebugValue
### useDeferredValue
### useTransition
### useId
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ requireComponents.keys().forEach(fileName => {



- #### `当使用vite时, 使用 import.meta.globEager 自动导入`
- #### `当使用vite时, 使用 import.meta.glob 自动导入`

```js
// require 自动导入实现
Expand All @@ -154,7 +154,8 @@ export default modules;

```js
// import 自动导入实现
const files = import.meta.globEager("./*.ts")
const files = import.meta.glob("./*.ts") // 异步加载
// const files = import.meta.glob("./*.ts", { eager: true }) // 配置 {eager: true} 则为同步加载
const modules: any = {};

for (const key in files) {
Expand All @@ -163,4 +164,6 @@ for (const key in files) {
}
}
export default modules;
```
```

- PS: 注意 `import.meta.globEager` 已经弃用,请使用 [import.meta.glob](https://cn.vitejs.dev/guide/migration-from-v2#importmetaglob) 来代替!
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
---
title: vite搭建react项目样式隔离方案
lang: zh-CN
feed:
enable: true
description: vite搭建react项目样式隔离方案
---

# vite搭建react项目样式隔离方案

> 本文作者:[onresize](https://github.com/onresize)
### css module方案

```js
// vite配置css module

css: {
modules: {
scopeBehaviour: "global" | "local",
localsConvention: 'camelCaseOnly' // 开启了 camelCase 格式变量名转换(box-left --> boxLeft)
}
}
```

```less
// index.module.less
.box {
.box1 {}
}
#box3 {}
```

```jsx
// App.jsx
import styles from './index.module.less'

const App = () => {
return (
<>
<div classname={`${styles.box} card`}>
<div classname={styles.box1}></div>
</div>
<div id={styles.box3}></div>
</>
)
}
```

### css in js方案

- #### styled-components
- #### 安装

```bash
yarn add styled-components
```

- #### 使用

```jsx
import styled from 'styled-components';

const Wrapper = styled.section`
margin: 0 auto;
width: 300px;
text-align: center;
`;

const Button = styled.button`
width: 100px;
color: white;
background: skyblue;
`;

render(
<Wrapper>
<Button>Hello World</Button>
</Wrapper>
);
```

- 总结

![](/AA_mdPics/css_module.png)
25 changes: 25 additions & 0 deletions docs/技术总结/踩坑总结/高频面试题.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
title: 高频面试题
lang: zh-CN
feed:
enable: true
description: 高频面试题
---

> 本文作者:[onresize](https://github.com/onresize)
- ### Promise终极面试题
<iframe
src="https://onresize.github.io/react-ts-vite-admin/SandPack?promise1"
style="width:100%; height: 500px; border:0; border-radius: 4px; overflow:hidden;"
allow="accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midipayment; usb; vr; xr-spatial-tracking"
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
></iframe>
- ### 输出什么
<iframe
src="https://onresize.github.io/react-ts-vite-admin/SandPack?val1"
style="width:100%; height: 500px; border:0; border-radius: 4px; overflow:hidden;"
allow="accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midipayment; usb; vr; xr-spatial-tracking"
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
></iframe>
Loading

0 comments on commit feaaf1e

Please sign in to comment.