From b0a036e5cfa289fab8d071d1f390812d08394107 Mon Sep 17 00:00:00 2001 From: neverland Date: Tue, 7 Dec 2021 15:50:47 +0800 Subject: [PATCH] docs: improve type (#10008) --- packages/vant-cli/changelog.md | 4 ++-- .../vant/docs/markdown/quickstart.zh-CN.md | 3 ++- packages/vant/src/cascader/README.md | 12 +++++------ packages/vant/src/cascader/README.zh-CN.md | 20 +++++++++---------- .../vant/src/config-provider/README.zh-CN.md | 2 +- packages/vant/src/form/README.md | 2 +- packages/vant/src/form/README.zh-CN.md | 4 ++-- packages/vant/src/image/README.zh-CN.md | 2 +- packages/vant/src/notify/README.md | 2 +- packages/vant/src/notify/README.zh-CN.md | 2 +- packages/vant/src/number-keyboard/README.md | 2 +- .../vant/src/number-keyboard/README.zh-CN.md | 2 +- packages/vant/src/pagination/README.zh-CN.md | 2 +- packages/vant/src/popover/README.md | 2 +- packages/vant/src/popover/README.zh-CN.md | 16 +++++++-------- packages/vant/src/tree-select/README.zh-CN.md | 2 +- 16 files changed, 40 insertions(+), 39 deletions(-) diff --git a/packages/vant-cli/changelog.md b/packages/vant-cli/changelog.md index 435fa3117..590a1eed5 100644 --- a/packages/vant-cli/changelog.md +++ b/packages/vant-cli/changelog.md @@ -292,7 +292,7 @@ yarn add sass `2020-12-01` --  升级 docsearch 3,优化搜索框样式 +- 升级 docsearch 3,优化搜索框样式 ## v3.0.0 @@ -475,7 +475,7 @@ yarn add sass `2020-01-15` -- 优化 help 命令  +- 优化 help 命令 - 优化控制台输出信息 ### v2.1.6 diff --git a/packages/vant/docs/markdown/quickstart.zh-CN.md b/packages/vant/docs/markdown/quickstart.zh-CN.md index 0f686985c..3883b1046 100644 --- a/packages/vant/docs/markdown/quickstart.zh-CN.md +++ b/packages/vant/docs/markdown/quickstart.zh-CN.md @@ -101,8 +101,9 @@ vue ui 我们提供了丰富的[示例工程](https://github.com/youzan/vant-demo),通过示例工程你可以了解如下内容: -- 基于 Vue Cli 和 Vant 搭建应用 +- 基于 Vite 和 Vant 搭建应用 - 基于 Nuxt 和 Vant 搭建应用 +- 基于 Vue Cli 和 Vant 搭建应用 - 配置按需引入组件 - 配置基于 Rem 的适配方案 - 配置基于 Viewport 的适配方案 diff --git a/packages/vant/src/cascader/README.md b/packages/vant/src/cascader/README.md index cde09899b..ea1e5c969 100644 --- a/packages/vant/src/cascader/README.md +++ b/packages/vant/src/cascader/README.md @@ -248,7 +248,7 @@ export default { | --- | --- | --- | --- | | title | Title | _string_ | - | | value | Value of selected option | _string \| number_ | - | -| options | Options | _Option[]_ | `[]` | +| options | Options | _CascaderOption[]_ | `[]` | | placeholder | Placeholder of unselected tab | _string_ | `Select` | | active-color | Active color | _string_ | `#ee0a24` | | swipeable `v3.0.11` | Whether to enable gestures to slide left and right | _boolean_ | `false` | @@ -256,14 +256,14 @@ export default { | close-icon `v3.0.10` | Close icon name | _string_ | `cross` | | field-names `v3.0.4` | Custom the fields of options | _object_ | `{ text: 'text', value: 'value', children: 'children' }` | -### Data Structure of Option +### Data Structure of CascaderOption | Key | Description | Type | | ------------------ | ------------------------- | --------------------------- | | text | Option text | _string_ | | value | Option value | _string \| number_ | | color `v3.1.0` | Text color | _string_ | -| children | Cascade children | _Option[]_ | +| children | Cascade children | _CascaderOption[]_ | | disabled `v3.1.2` | Whether to disable option | _boolean_ | | className `v3.1.0` | className for the option | _string \| Array \| object_ | @@ -271,8 +271,8 @@ export default { | Event | Description | Arguments | | --- | --- | --- | -| change | Emitted when active option changed | `{ value, selectedOptions, tabIndex }` | -| finish | Emitted when all options is selected | `{ value, selectedOptions, tabIndex }` | +| change | Emitted when active option changed | _{ value: string \| number, selectedOptions: CascaderOption[], tabIndex: number }_ | +| finish | Emitted when all options is selected | _{ value: string \| number, selectedOptions: CascaderOption[], tabIndex: number }_ | | close | Emitted when the close icon is clicked | - | | click-tab | Emitted when a tab is clicked | _activeTab: number, title: string_ | @@ -281,7 +281,7 @@ export default { | Name | Description | SlotProps | | --- | --- | --- | | title | Custom title | - | -| option `v3.1.4` | Custom option text | _{ option: Option, selected: boolean }_ | +| option `v3.1.4` | Custom option text | _{ option: CascaderOption, selected: boolean }_ | | options-top `v3.2.7` | Custom the content above the options | _{ tabIndex: number }_ | | options-bottom `v3.2.8` | Custom the content below the options | _{ tabIndex: number }_ | diff --git a/packages/vant/src/cascader/README.zh-CN.md b/packages/vant/src/cascader/README.zh-CN.md index 78fac0a94..09e737e46 100644 --- a/packages/vant/src/cascader/README.zh-CN.md +++ b/packages/vant/src/cascader/README.zh-CN.md @@ -258,7 +258,7 @@ export default { | --- | --- | --- | --- | | title | 顶部标题 | _string_ | - | | value | 选中项的值 | _string \| number_ | - | -| options | 可选项数据源 | _Option[]_ | `[]` | +| options | 可选项数据源 | _CascaderOption[]_ | `[]` | | placeholder | 未选中时的提示文案 | _string_ | `请选择` | | active-color | 选中状态的高亮颜色 | _string_ | `#ee0a24` | | swipeable `v3.0.11` | 是否开启手势左右滑动切换 | _boolean_ | `false` | @@ -266,7 +266,7 @@ export default { | close-icon `v3.0.10` | 关闭[图标名称](#/zh-CN/icon)或图片链接 | _string_ | `cross` | | field-names `v3.0.4` | 自定义 `options` 结构中的字段 | _object_ | `{ text: 'text', value: 'value', children: 'children' }` | -### Option 数据结构 +### CascaderOption 数据结构 `options` 属性是一个由对象构成的数组,数组中的每个对象配置一个可选项,对象可以包含以下值: @@ -275,25 +275,25 @@ export default { | text | 选项文字(必填) | _string_ | | value | 选项对应的值(必填) | _string \| number_ | | color `v3.1.0` | 选项文字颜色 | _string_ | -| children | 子选项列表 | _Option[]_ | +| children | 子选项列表 | _CascaderOption[]_ | | disabled `v3.1.2` | 是否禁用选项 | _boolean_ | | className `v3.1.0` | 为对应列添加额外的 class | _string \| Array \| object_ | ### Events -| 事件 | 说明 | 回调参数 | -| --------- | ---------------------- | -------------------------------------- | -| change | 选中项变化时触发 | `{ value, selectedOptions, tabIndex }` | -| finish | 全部选项选择完成后触发 | `{ value, selectedOptions, tabIndex }` | -| close | 点击关闭图标时触发 | - | -| click-tab | 点击标签时触发 | _tabIndex: number, title: string_ | +| 事件 | 说明 | 回调参数 | +| --- | --- | --- | +| change | 选中项变化时触发 | _{ value: string \| number, selectedOptions: CascaderOption[], tabIndex: number }_ | +| finish | 全部选项选择完成后触发 | _{ value: string \| number, selectedOptions: CascaderOption[], tabIndex: number }_ | +| close | 点击关闭图标时触发 | - | +| click-tab | 点击标签时触发 | _tabIndex: number, title: string_ | ### Slots | 名称 | 说明 | 参数 | | --- | --- | --- | | title | 自定义顶部标题 | - | -| option `v3.1.4` | 自定义选项文字 | _{ option: Option, selected: boolean }_ | +| option `v3.1.4` | 自定义选项文字 | _{ option: CascaderOption, selected: boolean }_ | | options-top `v3.2.7` | 自定义选项上方的内容 | _{ tabIndex: number }_ | | options-bottom `v3.2.8` | 自定义选项下方的内容 | _{ tabIndex: number }_ | diff --git a/packages/vant/src/config-provider/README.zh-CN.md b/packages/vant/src/config-provider/README.zh-CN.md index 7abfe3982..2e2cc86ac 100644 --- a/packages/vant/src/config-provider/README.zh-CN.md +++ b/packages/vant/src/config-provider/README.zh-CN.md @@ -120,7 +120,7 @@ Vant 中的 CSS 变量分为 **基础变量** 和 **组件变量**。组件变 #### 修改变量 -由于 CSS 变量继承机制的原因, 两者的修改方式有一定差异: +由于 CSS 变量继承机制的原因,两者的修改方式有一定差异: - 基础变量只能通过 `root 选择器` 修改,不能通过 `ConfigProvider 组件` 修改。 - 组件变量可以通过 `root 选择器` 和 `ConfigProvider 组件` 修改。 diff --git a/packages/vant/src/form/README.md b/packages/vant/src/form/README.md index 99c2be85b..3e8ad2e12 100644 --- a/packages/vant/src/form/README.md +++ b/packages/vant/src/form/README.md @@ -492,7 +492,7 @@ export default { | Attribute | Description | Type | Default | | --- | --- | --- | --- | | label-width | Field label width | _number \| string_ | `6.2em` | -| label-align | Field label align, can be set to `center` `right` | _string_ | `left` | +| label-align | Field label align, can be set to `center` `right` | _string_ | `left` | | input-align | Field input align, can be set to `center` `right` | _string_ | `left` | | error-message-align | Error message align, can be set to `center` `right` | _string_ | `left` | | validate-trigger | When to validate the form,can be set to `onChange`、`onSubmit` | _string_ | `onBlur` | diff --git a/packages/vant/src/form/README.zh-CN.md b/packages/vant/src/form/README.zh-CN.md index 226746286..f701df74a 100644 --- a/packages/vant/src/form/README.zh-CN.md +++ b/packages/vant/src/form/README.zh-CN.md @@ -524,7 +524,7 @@ export default { | 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | | label-width | 表单项 label 宽度,默认单位为`px` | _number \| string_ | `6.2em` | -| label-align |  表单项 label 对齐方式,可选值为 `center` `right` | _string_ | `left` | +| label-align | 表单项 label 对齐方式,可选值为 `center` `right` | _string_ | `left` | | input-align | 输入框对齐方式,可选值为 `center` `right` | _string_ | `left` | | error-message-align | 错误提示文案对齐方式,可选值为 `center` `right` | _string_ | `left` | | validate-trigger | 表单校验触发时机,可选值为 `onChange`、`onSubmit`,详见下表 | _string_ | `onBlur` | @@ -552,7 +552,7 @@ export default { | trigger | 本项规则的触发时机,可选值为 `onChange`、`onBlur` | _string_ | | formatter | 格式化函数,将表单项的值转换后进行校验 | _(value, rule) => any_ | -### validate-trigger  可选值 +### validate-trigger 可选值 通过 `validate-trigger` 属性可以自定义表单校验的触发时机。 diff --git a/packages/vant/src/image/README.zh-CN.md b/packages/vant/src/image/README.zh-CN.md index 501706520..c0de0c514 100644 --- a/packages/vant/src/image/README.zh-CN.md +++ b/packages/vant/src/image/README.zh-CN.md @@ -116,7 +116,7 @@ app.use(Lazyload); | icon-size `v3.0.11` | 加载图标和失败图标的大小 | _number \| string_ | `32px` | | icon-prefix | 图标类名前缀,等同于 Icon 组件的 [class-prefix 属性](#/zh-CN/icon#props) | _string_ | `van-icon` | -### 图片填充模式  +### 图片填充模式 | 名称 | 含义 | | ---------- | ------------------------------------------------------ | diff --git a/packages/vant/src/notify/README.md b/packages/vant/src/notify/README.md index 37984e3f2..b0bbc6e25 100644 --- a/packages/vant/src/notify/README.md +++ b/packages/vant/src/notify/README.md @@ -107,7 +107,7 @@ export default { | Attribute | Description | Type | Default | | --- | --- | --- | --- | -| type | Can be set to `primary` `success` `warning` | _string_ | `danger` | +| type | Can be set to `primary` `success` `warning` | _NotifyType_ | `danger` | | message | Message | _string_ | - | | duration | Duration(ms), won't disappear if value is 0 | _number \| string_ | `3000` | | color | Message color | _string_ | `white` | diff --git a/packages/vant/src/notify/README.zh-CN.md b/packages/vant/src/notify/README.zh-CN.md index 465348abe..28e2ac85e 100644 --- a/packages/vant/src/notify/README.zh-CN.md +++ b/packages/vant/src/notify/README.zh-CN.md @@ -155,7 +155,7 @@ export default { | 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | -| type | 类型,可选值为 `primary` `success` `warning` | _string_ | `danger` | +| type | 类型,可选值为 `primary` `success` `warning` | _NotifyType_ | `danger` | | message | 展示文案,支持通过`\n`换行 | _string_ | - | | duration | 展示时长(ms),值为 0 时,notify 不会消失 | _number \| string_ | `3000` | | color | 字体颜色 | _string_ | `white` | diff --git a/packages/vant/src/number-keyboard/README.md b/packages/vant/src/number-keyboard/README.md index 51ce01f7b..1f982226d 100644 --- a/packages/vant/src/number-keyboard/README.md +++ b/packages/vant/src/number-keyboard/README.md @@ -190,7 +190,7 @@ export default { | Event | Description | Arguments | | --- | --- | --- | -| input | Emitted when a key is pressed | key: Content of the key | +| input | Emitted when a key is pressed | _key: string_ | | delete | Emitted when the delete key is pressed | - | | close | Emitted when the close button is clicked | - | | blur | Emitted when the close button is clicked or the keyboard is blurred | - | diff --git a/packages/vant/src/number-keyboard/README.zh-CN.md b/packages/vant/src/number-keyboard/README.zh-CN.md index e16b9421c..61a8c858e 100644 --- a/packages/vant/src/number-keyboard/README.zh-CN.md +++ b/packages/vant/src/number-keyboard/README.zh-CN.md @@ -197,7 +197,7 @@ export default { | 事件名 | 说明 | 回调参数 | | ------ | ------------------------------ | ------------- | -| input | 点击按键时触发 | key: 按键内容 | +| input | 点击按键时触发 | _key: string_ | | delete | 点击删除键时触发 | - | | close | 点击关闭按钮时触发 | - | | blur | 点击关闭按钮或非键盘区域时触发 | - | diff --git a/packages/vant/src/pagination/README.zh-CN.md b/packages/vant/src/pagination/README.zh-CN.md index 9e583a5e9..77b062e2f 100644 --- a/packages/vant/src/pagination/README.zh-CN.md +++ b/packages/vant/src/pagination/README.zh-CN.md @@ -39,7 +39,7 @@ export default { ### 简单模式 - 将 `mode` 设置为 `simple` 来切换到简单模式,此时分页器不会展示具体的页码按钮。 +将 `mode` 设置为 `simple` 来切换到简单模式,此时分页器不会展示具体的页码按钮。 ```html diff --git a/packages/vant/src/popover/README.md b/packages/vant/src/popover/README.md index f42a475a8..84133aca9 100644 --- a/packages/vant/src/popover/README.md +++ b/packages/vant/src/popover/README.md @@ -241,7 +241,7 @@ export default { | Event | Description | Arguments | | --- | --- | --- | -| select | Emitted when an action is clicked | _action: Action, index: number_ | +| select | Emitted when an action is clicked | _action: PopoverAction, index: number_ | | open | Emitted when opening Popover | - | | close | Emitted when closing Popover | - | | opened | Emitted when Popover is opened | - | diff --git a/packages/vant/src/popover/README.zh-CN.md b/packages/vant/src/popover/README.zh-CN.md index 32c8d6915..9ab31930e 100644 --- a/packages/vant/src/popover/README.zh-CN.md +++ b/packages/vant/src/popover/README.zh-CN.md @@ -251,14 +251,14 @@ export default { ### Events -| 事件名 | 说明 | 回调参数 | -| ------------- | ------------------------ | ------------------------------- | -| select | 点击选项时触发 | _action: Action, index: number_ | -| open | 打开菜单时触发 | - | -| close | 关闭菜单时触发 | - | -| opened | 打开菜单且动画结束后触发 | - | -| closed | 关闭菜单且动画结束后触发 | - | -| click-overlay | 点击遮罩层时触发 | _event: MouseEvent_ | +| 事件名 | 说明 | 回调参数 | +| --- | --- | --- | +| select | 点击选项时触发 | _action: PopoverAction, index: number_ | +| open | 打开菜单时触发 | - | +| close | 关闭菜单时触发 | - | +| opened | 打开菜单且动画结束后触发 | - | +| closed | 关闭菜单且动画结束后触发 | - | +| click-overlay | 点击遮罩层时触发 | _event: MouseEvent_ | ### Slots diff --git a/packages/vant/src/tree-select/README.zh-CN.md b/packages/vant/src/tree-select/README.zh-CN.md index b09817cb9..6d6150e04 100644 --- a/packages/vant/src/tree-select/README.zh-CN.md +++ b/packages/vant/src/tree-select/README.zh-CN.md @@ -209,7 +209,7 @@ export default { { // 导航名称 text: '所有城市', - // 导航名称右上角徽标 + // 导航名称右上角徽标 badge: 3, // 是否在导航名称右上角显示小红点 dot: true,