File tree Expand file tree Collapse file tree 4 files changed +85
-0
lines changed
Expand file tree Collapse file tree 4 files changed +85
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ highlight : darcula
3+ theme : smartblue
4+ ---
5+
6+ # antd-mobile 组件库
7+
8+ ## 1. 前言
9+
10+ 大家好,我是[ 若川] ( https://ruochuan12.github.io ) ,欢迎关注我的[ 公众号:若川视野] ( https://mp.weixin.qq.com/s/MacNfeTPODNMLLFdzrULow ) 。我倾力持续组织了 3 年多[ 每周大家一起学习 200 行左右的源码共读活动] ( https://juejin.cn/post/7079706017579139102 ) ,感兴趣的可以[ 点此扫码加我微信 ` ruochuan02 ` 参与] ( https://juejin.cn/pin/7217386885793595453 ) 。另外,想学源码,极力推荐关注我写的专栏[ 《学习源码整体架构系列》] ( https://juejin.cn/column/6960551178908205093 ) ,目前是掘金关注人数(6k+人)第一的专栏,写有几十篇源码文章。
11+
12+ 打算写一个 antd-mobile 源码系列。
13+
14+ [ antd-mobile 仓库] ( https://github.com/ant-design/ant-design-mobile )
15+
16+ [ Toast 轻提示] ( https://mobile.ant.design/zh/components/toast )
17+
18+ [ 贡献文档] ( https://github.com/ant-design/ant-design-mobile/blob/master/.github/CONTRIBUTING.md )
19+
20+ ## 准备工作
21+
22+ ``` bash
23+ git clone https://github.com/ant-design/ant-design-mobile.git
24+ cd ant-design-mobile
25+ pnpm install
26+ pnpm start
27+ ```
28+
29+ ## Toast.show
30+
31+ ``` tsx
32+ <DemoBlock title = ' 基础用法' >
33+ <Button
34+ onClick = { () =>
35+ Toast .show ({
36+ content: ' Hello World, This is a long text' ,
37+ afterClose : () => {
38+ console .log (' after' )
39+ },
40+ })
41+ }
42+ >
43+ 轻提示
44+ </Button >
45+ </DemoBlock >
46+ ```
47+
48+ 如果是你会怎么实现 Toast。
49+
50+ 实现简版
51+
52+ ``` ts
53+ const Toast = (props ) => {
54+ return <div >{props.content }< / div >
55+ }
56+ ```
Original file line number Diff line number Diff line change @@ -217,6 +217,26 @@ appConfig 配置
217217#### readConfig 读取配置
218218
219219``` ts
220+ export function readConfig<T extends IReadConfigOptions > (configPath : string , options : T = {} as T ) {
221+ let result: any = {}
222+ if (fs .existsSync (configPath )) {
223+ if (REG_JSON .test (configPath )) {
224+ result = fs .readJSONSync (configPath )
225+ } else {
226+ result = requireWithEsbuild (configPath , {
227+ customConfig: {
228+ },
229+ customSwcConfig: {
230+ },
231+ })
232+ }
233+
234+ result = getModuleDefaultExport (result )
235+ } else {
236+ result = readPageConfig (configPath )
237+ }
238+ return result
239+ }
220240```
221241
222242## getPages 获取页面信息
Original file line number Diff line number Diff line change @@ -258,6 +258,15 @@ export default defineConfig({
258258 // // '../../',
259259 // ],
260260 } ,
261+ {
262+ text : "antd-mobile 组件库源码" , // 必要的
263+ // path: '/about/', // 可选的, 应该是一个绝对路径
264+ // collapsible: true, // 可选的, 默认值是 true,
265+ // sidebarDepth: 2, // 可选的, 默认值是 1
266+ items : [
267+ "/antd-mobile/toast/" ,
268+ ] ,
269+ } ,
261270 {
262271 text : "taro源码揭秘" , // 必要的
263272 // path: '/about/', // 可选的, 应该是一个绝对路径
You can’t perform that action at this time.
0 commit comments