From d8b6ad7d543c599874b84148b5911889544a775e Mon Sep 17 00:00:00 2001 From: neverland Date: Wed, 15 Nov 2017 20:08:51 -0600 Subject: [PATCH] [new feature] add i18n support (#310) * fix: Tabbar icon line-height * [new feature] progress add showPivot prop * [new feature] TabItem support vue-router * [new feature] update document header style * [Doc] add toast english ducoment * [new feature] add i18n support * feat: Extract demos from markdown * feat: Base components demos * [new feature] complete demo extract & translate * [fix] text cases * fix: add deepAssign test cases * fix: changelog detail * [new feature] AddressEdit support i18n --- .github/CONTRIBUTING.zh-CN.md | 8 +- .github/MARKDOWN.md | 38 +- build/bin/build-entry.js | 137 ++++--- build/webpack.config.dev.js | 19 +- docs/demos/common.js | 72 ++++ docs/demos/index.js | 57 +++ docs/{ => demos}/mock/area.json | 0 docs/{ => demos}/mock/sku.js | 0 docs/demos/views/actionsheet.vue | 81 +++++ docs/demos/views/address-edit.vue | 69 ++++ docs/demos/views/address-list.vue | 60 ++++ docs/demos/views/area.vue | 38 ++ docs/demos/views/badge.vue | 54 +++ docs/demos/views/button.vue | 92 +++++ docs/demos/views/card.vue | 38 ++ docs/demos/views/cell-swipe.vue | 51 +++ docs/demos/views/cell.vue | 86 +++++ docs/demos/views/checkbox.vue | 77 ++++ docs/demos/views/contact.vue | 116 ++++++ docs/demos/views/coupon.vue | 96 +++++ docs/demos/views/datetime-picker.vue | 61 ++++ docs/demos/views/dialog.vue | 60 ++++ docs/demos/views/field.vue | 105 ++++++ docs/demos/views/goods-action.vue | 52 +++ .../en-US/icon.md => demos/views/icon.vue} | 90 +++-- docs/demos/views/image-preview.vue | 51 +++ docs/demos/views/layout.vue | 65 ++++ docs/demos/views/lazyload.vue | 82 +++++ docs/demos/views/loading.vue | 44 +++ docs/demos/views/nav-bar.vue | 18 + docs/demos/views/notice-bar.vue | 44 +++ docs/demos/views/number-keyboard.vue | 59 +++ docs/demos/views/panel.vue | 35 ++ docs/demos/views/password-input.vue | 47 +++ docs/demos/views/picker.vue | 74 ++++ docs/demos/views/popup.vue | 112 ++++++ docs/demos/views/progress.vue | 48 +++ docs/demos/views/pull-refresh.vue | 49 +++ docs/demos/views/radio.vue | 77 ++++ docs/demos/views/search.vue | 68 ++++ docs/demos/views/sku.vue | 115 ++++++ docs/demos/views/stepper.vue | 34 ++ docs/demos/views/steps.vue | 113 ++++++ docs/demos/views/submit-bar.vue | 76 ++++ docs/demos/views/swipe.vue | 80 +++++ docs/demos/views/switch-cell.vue | 45 +++ docs/demos/views/switch.vue | 61 ++++ docs/demos/views/tab.vue | 112 ++++++ docs/demos/views/tabbar.vue | 60 ++++ docs/demos/views/tag.vue | 53 +++ docs/demos/views/toast.vue | 95 +++++ docs/demos/views/tree-select.vue | 119 ++++++ docs/demos/views/uploader.vue | 31 ++ docs/demos/views/waterfall.vue | 77 ++++ docs/examples-docs/en-US/dialog.md | 126 ------- docs/examples-docs/en-US/image-preview.md | 52 --- docs/examples-docs/en-US/popup.md | 119 ------ docs/examples-docs/en-US/tab.md | 339 ------------------ docs/examples-docs/en-US/toast.md | 160 --------- docs/examples-docs/en-US/uploader.md | 57 --- docs/examples-docs/zh-CN/actionsheet.md | 181 ---------- docs/examples-docs/zh-CN/dialog.md | 132 ------- docs/examples-docs/zh-CN/icon.md | 172 --------- docs/examples-docs/zh-CN/image-preview.md | 89 ----- docs/examples-docs/zh-CN/lazyload.md | 153 -------- docs/examples-docs/zh-CN/loading.md | 53 --- docs/examples-docs/zh-CN/popup.md | 154 -------- docs/examples-docs/zh-CN/tab.md | 257 ------------- docs/examples-docs/zh-CN/toast.md | 168 --------- .../en-US/actionsheet.md | 42 +-- .../en-US/address-edit.md | 52 +-- .../en-US/address-list.md | 43 --- .../{examples-docs => markdown}/en-US/area.md | 43 +-- .../en-US/badge.md | 23 +- .../en-US/button.md | 18 +- .../{examples-docs => markdown}/en-US/card.md | 14 - .../en-US/cell-swipe.md | 2 - .../{examples-docs => markdown}/en-US/cell.md | 40 +-- .../en-US/changelog.md | 6 +- .../en-US/checkbox.md | 52 +-- .../en-US/contact.md | 78 +--- .../en-US/coupon.md | 72 +--- .../en-US/datetime-picker.md | 37 +- docs/markdown/en-US/dialog.md | 63 ++++ .../en-US/field.md | 27 +- .../en-US/goods-action.md | 18 +- docs/markdown/en-US/icon.md | 23 ++ docs/markdown/en-US/image-preview.md | 32 ++ .../en-US/layout.md | 8 +- .../en-US/lazyload.md | 38 +- .../en-US/loading.md | 18 +- .../en-US/nav-bar.md | 18 +- .../en-US/notice-bar.md | 8 +- .../en-US/number-keyboard.md | 28 +- .../en-US/panel.md | 8 +- .../en-US/password-input.md | 8 +- .../en-US/picker.md | 65 +--- docs/markdown/en-US/popup.md | 48 +++ .../en-US/progress.md | 26 +- .../en-US/pull-refresh.md | 32 -- .../en-US/quickstart.md | 0 .../en-US/radio.md | 81 +---- .../en-US/search.md | 31 +- docs/{examples-docs => markdown}/en-US/sku.md | 144 +++----- .../en-US/stepper.md | 25 +- .../en-US/steps.md | 48 +-- .../en-US/submit-bar.md | 26 +- .../en-US/swipe.md | 19 - .../en-US/switch-cell.md | 25 +- .../en-US/switch.md | 42 +-- docs/markdown/en-US/tab.md | 125 +++++++ .../en-US/tabbar.md | 25 +- docs/{examples-docs => markdown}/en-US/tag.md | 6 - docs/markdown/en-US/theme.md | 55 +++ docs/markdown/en-US/toast.md | 73 ++++ .../en-US/tree-select.md | 87 +---- docs/markdown/en-US/uploader.md | 45 +++ .../en-US/waterfall.md | 32 -- docs/markdown/index.js | 116 ++++++ docs/markdown/zh-CN/actionsheet.md | 86 +++++ .../zh-CN/address-edit.md | 50 +-- .../zh-CN/address-list.md | 44 +-- .../{examples-docs => markdown}/zh-CN/area.md | 40 +-- .../zh-CN/badge.md | 38 -- .../zh-CN/button.md | 46 +-- .../{examples-docs => markdown}/zh-CN/card.md | 26 +- .../zh-CN/cell-swipe.md | 22 +- .../{examples-docs => markdown}/zh-CN/cell.md | 57 +-- .../zh-CN/changelog-generated.md | 0 .../zh-CN/changelog.md | 6 +- .../zh-CN/checkbox.md | 57 +-- .../zh-CN/contact.md | 85 +---- .../zh-CN/coupon.md | 81 +---- .../zh-CN/datetime-picker.md | 51 +-- docs/markdown/zh-CN/dialog.md | 63 ++++ .../zh-CN/field.md | 29 -- .../zh-CN/goods-action.md | 25 -- docs/markdown/zh-CN/icon.md | 23 ++ docs/markdown/zh-CN/image-preview.md | 36 ++ .../zh-CN/layout.md | 28 -- docs/markdown/zh-CN/lazyload.md | 67 ++++ docs/markdown/zh-CN/loading.md | 38 ++ .../zh-CN/nav-bar.md | 18 +- .../zh-CN/notice-bar.md | 17 +- .../zh-CN/number-keyboard.md | 32 -- .../zh-CN/panel.md | 33 +- .../zh-CN/password-input.md | 28 +- .../zh-CN/picker.md | 84 +---- docs/markdown/zh-CN/popup.md | 48 +++ .../zh-CN/progress.md | 34 +- .../zh-CN/pull-refresh.md | 54 --- .../zh-CN/quickstart.md | 0 .../zh-CN/radio.md | 95 +---- .../zh-CN/search.md | 41 +-- docs/{examples-docs => markdown}/zh-CN/sku.md | 151 +++----- .../zh-CN/stepper.md | 31 +- .../zh-CN/steps.md | 78 +--- .../zh-CN/submit-bar.md | 52 +-- .../zh-CN/swipe.md | 55 --- .../zh-CN/switch-cell.md | 21 +- .../zh-CN/switch.md | 48 +-- docs/markdown/zh-CN/tab.md | 129 +++++++ .../zh-CN/tabbar.md | 41 +-- docs/{examples-docs => markdown}/zh-CN/tag.md | 21 +- .../zh-CN/theme.md | 0 docs/markdown/zh-CN/toast.md | 74 ++++ .../zh-CN/tree-select.md | 88 +---- .../zh-CN/uploader.md | 28 +- .../zh-CN/waterfall.md | 56 +-- docs/src/DocsApp.vue | 21 +- docs/src/WapApp.vue | 1 - docs/src/components/demo-list.vue | 18 +- docs/src/components/demo.vue | 99 ----- docs/src/doc.config.js | 27 +- docs/src/examples.js | 15 +- docs/src/index.js | 4 +- docs/src/router.config.js | 17 +- docs/src/utils/iframe-router.js | 17 +- docs/src/utils/lang.js | 18 +- package.json | 9 +- packages/address-edit/Detail.vue | 11 +- packages/address-edit/index.vue | 62 ++-- packages/address-edit/theme.md | 55 +++ packages/area/index.vue | 4 +- packages/badge-group/index.vue | 1 - packages/cell-swipe/index.vue | 4 +- packages/checkbox/index.vue | 2 +- packages/contact-card/index.vue | 14 +- packages/contact-edit/index.vue | 25 +- packages/contact-list/index.vue | 14 +- packages/dialog/dialog.vue | 17 +- packages/dialog/index.js | 4 +- packages/index.js | 9 +- packages/locale/index.js | 45 +++ packages/locale/lang/en-US.js | 68 ++++ packages/locale/lang/zh-CN.js | 72 ++++ .../{picker-column.vue => PickerColumn.vue} | 0 packages/picker/index.vue | 9 +- packages/pull-refresh/index.vue | 24 +- packages/search/index.vue | 51 ++- packages/utils/camelize.js | 4 + packages/utils/deep-assign.js | 34 ++ packages/utils/get.js | 9 + packages/vant-css/src/contact-card.css | 1 + packages/vant-css/src/progress.css | 4 +- test/unit/specs/address-edit.spec.js | 2 +- test/unit/specs/deep-assign.spec.js | 96 +++++ test/unit/specs/picker.spec.js | 2 +- test/unit/specs/popup.spec.js | 2 +- yarn.lock | 139 ++++--- 210 files changed, 5563 insertions(+), 5530 deletions(-) create mode 100644 docs/demos/common.js create mode 100644 docs/demos/index.js rename docs/{ => demos}/mock/area.json (100%) rename docs/{ => demos}/mock/sku.js (100%) create mode 100644 docs/demos/views/actionsheet.vue create mode 100644 docs/demos/views/address-edit.vue create mode 100644 docs/demos/views/address-list.vue create mode 100644 docs/demos/views/area.vue create mode 100644 docs/demos/views/badge.vue create mode 100644 docs/demos/views/button.vue create mode 100644 docs/demos/views/card.vue create mode 100644 docs/demos/views/cell-swipe.vue create mode 100644 docs/demos/views/cell.vue create mode 100644 docs/demos/views/checkbox.vue create mode 100644 docs/demos/views/contact.vue create mode 100644 docs/demos/views/coupon.vue create mode 100644 docs/demos/views/datetime-picker.vue create mode 100644 docs/demos/views/dialog.vue create mode 100644 docs/demos/views/field.vue create mode 100644 docs/demos/views/goods-action.vue rename docs/{examples-docs/en-US/icon.md => demos/views/icon.vue} (57%) create mode 100644 docs/demos/views/image-preview.vue create mode 100644 docs/demos/views/layout.vue create mode 100644 docs/demos/views/lazyload.vue create mode 100644 docs/demos/views/loading.vue create mode 100644 docs/demos/views/nav-bar.vue create mode 100644 docs/demos/views/notice-bar.vue create mode 100644 docs/demos/views/number-keyboard.vue create mode 100644 docs/demos/views/panel.vue create mode 100644 docs/demos/views/password-input.vue create mode 100644 docs/demos/views/picker.vue create mode 100644 docs/demos/views/popup.vue create mode 100644 docs/demos/views/progress.vue create mode 100644 docs/demos/views/pull-refresh.vue create mode 100644 docs/demos/views/radio.vue create mode 100644 docs/demos/views/search.vue create mode 100644 docs/demos/views/sku.vue create mode 100644 docs/demos/views/stepper.vue create mode 100644 docs/demos/views/steps.vue create mode 100644 docs/demos/views/submit-bar.vue create mode 100644 docs/demos/views/swipe.vue create mode 100644 docs/demos/views/switch-cell.vue create mode 100644 docs/demos/views/switch.vue create mode 100644 docs/demos/views/tab.vue create mode 100644 docs/demos/views/tabbar.vue create mode 100644 docs/demos/views/tag.vue create mode 100644 docs/demos/views/toast.vue create mode 100644 docs/demos/views/tree-select.vue create mode 100644 docs/demos/views/uploader.vue create mode 100644 docs/demos/views/waterfall.vue delete mode 100644 docs/examples-docs/en-US/dialog.md delete mode 100644 docs/examples-docs/en-US/image-preview.md delete mode 100644 docs/examples-docs/en-US/popup.md delete mode 100644 docs/examples-docs/en-US/tab.md delete mode 100644 docs/examples-docs/en-US/toast.md delete mode 100644 docs/examples-docs/en-US/uploader.md delete mode 100644 docs/examples-docs/zh-CN/actionsheet.md delete mode 100644 docs/examples-docs/zh-CN/dialog.md delete mode 100644 docs/examples-docs/zh-CN/icon.md delete mode 100644 docs/examples-docs/zh-CN/image-preview.md delete mode 100644 docs/examples-docs/zh-CN/lazyload.md delete mode 100644 docs/examples-docs/zh-CN/loading.md delete mode 100644 docs/examples-docs/zh-CN/popup.md delete mode 100644 docs/examples-docs/zh-CN/tab.md delete mode 100644 docs/examples-docs/zh-CN/toast.md rename docs/{examples-docs => markdown}/en-US/actionsheet.md (59%) rename docs/{examples-docs => markdown}/en-US/address-edit.md (75%) rename docs/{examples-docs => markdown}/en-US/address-list.md (67%) rename docs/{examples-docs => markdown}/en-US/area.md (81%) rename docs/{examples-docs => markdown}/en-US/badge.md (74%) rename docs/{examples-docs => markdown}/en-US/button.md (84%) rename docs/{examples-docs => markdown}/en-US/card.md (84%) rename docs/{examples-docs => markdown}/en-US/cell-swipe.md (97%) rename docs/{examples-docs => markdown}/en-US/cell.md (68%) rename docs/{examples-docs => markdown}/en-US/changelog.md (99%) rename docs/{examples-docs => markdown}/en-US/checkbox.md (71%) rename docs/{examples-docs => markdown}/en-US/contact.md (74%) rename docs/{examples-docs => markdown}/en-US/coupon.md (72%) rename docs/{examples-docs => markdown}/en-US/datetime-picker.md (74%) create mode 100644 docs/markdown/en-US/dialog.md rename docs/{examples-docs => markdown}/en-US/field.md (87%) rename docs/{examples-docs => markdown}/en-US/goods-action.md (87%) create mode 100644 docs/markdown/en-US/icon.md create mode 100644 docs/markdown/en-US/image-preview.md rename docs/{examples-docs => markdown}/en-US/layout.md (97%) rename docs/{examples-docs => markdown}/en-US/lazyload.md (79%) rename docs/{examples-docs => markdown}/en-US/loading.md (52%) rename docs/{examples-docs => markdown}/en-US/nav-bar.md (67%) rename docs/{examples-docs => markdown}/en-US/notice-bar.md (90%) rename docs/{examples-docs => markdown}/en-US/number-keyboard.md (82%) rename docs/{examples-docs => markdown}/en-US/panel.md (89%) rename docs/{examples-docs => markdown}/en-US/password-input.md (95%) rename docs/{examples-docs => markdown}/en-US/picker.md (68%) create mode 100644 docs/markdown/en-US/popup.md rename docs/{examples-docs => markdown}/en-US/progress.md (51%) rename docs/{examples-docs => markdown}/en-US/pull-refresh.md (73%) rename docs/{examples-docs => markdown}/en-US/quickstart.md (100%) rename docs/{examples-docs => markdown}/en-US/radio.md (53%) rename docs/{examples-docs => markdown}/en-US/search.md (81%) rename docs/{examples-docs => markdown}/en-US/sku.md (66%) rename docs/{examples-docs => markdown}/en-US/stepper.md (78%) rename docs/{examples-docs => markdown}/en-US/steps.md (66%) rename docs/{examples-docs => markdown}/en-US/submit-bar.md (78%) rename docs/{examples-docs => markdown}/en-US/swipe.md (73%) rename docs/{examples-docs => markdown}/en-US/switch-cell.md (75%) rename docs/{examples-docs => markdown}/en-US/switch.md (65%) create mode 100644 docs/markdown/en-US/tab.md rename docs/{examples-docs => markdown}/en-US/tabbar.md (79%) rename docs/{examples-docs => markdown}/en-US/tag.md (93%) create mode 100644 docs/markdown/en-US/theme.md create mode 100644 docs/markdown/en-US/toast.md rename docs/{examples-docs => markdown}/en-US/tree-select.md (53%) create mode 100644 docs/markdown/en-US/uploader.md rename docs/{examples-docs => markdown}/en-US/waterfall.md (72%) create mode 100644 docs/markdown/index.js create mode 100644 docs/markdown/zh-CN/actionsheet.md rename docs/{examples-docs => markdown}/zh-CN/address-edit.md (75%) rename docs/{examples-docs => markdown}/zh-CN/address-list.md (67%) rename docs/{examples-docs => markdown}/zh-CN/area.md (82%) rename docs/{examples-docs => markdown}/zh-CN/badge.md (73%) rename docs/{examples-docs => markdown}/zh-CN/button.md (73%) rename docs/{examples-docs => markdown}/zh-CN/card.md (71%) rename docs/{examples-docs => markdown}/zh-CN/cell-swipe.md (64%) rename docs/{examples-docs => markdown}/zh-CN/cell.md (65%) rename docs/{examples-docs => markdown}/zh-CN/changelog-generated.md (100%) rename docs/{examples-docs => markdown}/zh-CN/changelog.md (99%) rename docs/{examples-docs => markdown}/zh-CN/checkbox.md (72%) rename docs/{examples-docs => markdown}/zh-CN/contact.md (73%) rename docs/{examples-docs => markdown}/zh-CN/coupon.md (72%) rename docs/{examples-docs => markdown}/zh-CN/datetime-picker.md (74%) create mode 100644 docs/markdown/zh-CN/dialog.md rename docs/{examples-docs => markdown}/zh-CN/field.md (87%) rename docs/{examples-docs => markdown}/zh-CN/goods-action.md (83%) create mode 100644 docs/markdown/zh-CN/icon.md create mode 100644 docs/markdown/zh-CN/image-preview.md rename docs/{examples-docs => markdown}/zh-CN/layout.md (79%) create mode 100644 docs/markdown/zh-CN/lazyload.md create mode 100644 docs/markdown/zh-CN/loading.md rename docs/{examples-docs => markdown}/zh-CN/nav-bar.md (67%) rename docs/{examples-docs => markdown}/zh-CN/notice-bar.md (84%) rename docs/{examples-docs => markdown}/zh-CN/number-keyboard.md (80%) rename docs/{examples-docs => markdown}/zh-CN/panel.md (58%) rename docs/{examples-docs => markdown}/zh-CN/password-input.md (78%) rename docs/{examples-docs => markdown}/zh-CN/picker.md (53%) create mode 100644 docs/markdown/zh-CN/popup.md rename docs/{examples-docs => markdown}/zh-CN/progress.md (50%) rename docs/{examples-docs => markdown}/zh-CN/pull-refresh.md (61%) rename docs/{examples-docs => markdown}/zh-CN/quickstart.md (100%) rename docs/{examples-docs => markdown}/zh-CN/radio.md (50%) rename docs/{examples-docs => markdown}/zh-CN/search.md (76%) rename docs/{examples-docs => markdown}/zh-CN/sku.md (65%) rename docs/{examples-docs => markdown}/zh-CN/stepper.md (74%) rename docs/{examples-docs => markdown}/zh-CN/steps.md (60%) rename docs/{examples-docs => markdown}/zh-CN/submit-bar.md (62%) rename docs/{examples-docs => markdown}/zh-CN/swipe.md (57%) rename docs/{examples-docs => markdown}/zh-CN/switch-cell.md (79%) rename docs/{examples-docs => markdown}/zh-CN/switch.md (64%) create mode 100644 docs/markdown/zh-CN/tab.md rename docs/{examples-docs => markdown}/zh-CN/tabbar.md (76%) rename docs/{examples-docs => markdown}/zh-CN/tag.md (84%) rename docs/{examples-docs => markdown}/zh-CN/theme.md (100%) create mode 100644 docs/markdown/zh-CN/toast.md rename docs/{examples-docs => markdown}/zh-CN/tree-select.md (55%) rename docs/{examples-docs => markdown}/zh-CN/uploader.md (74%) rename docs/{examples-docs => markdown}/zh-CN/waterfall.md (67%) delete mode 100644 docs/src/components/demo.vue create mode 100644 packages/address-edit/theme.md create mode 100644 packages/locale/index.js create mode 100644 packages/locale/lang/en-US.js create mode 100644 packages/locale/lang/zh-CN.js rename packages/picker/{picker-column.vue => PickerColumn.vue} (100%) create mode 100644 packages/utils/camelize.js create mode 100644 packages/utils/deep-assign.js create mode 100644 packages/utils/get.js create mode 100644 test/unit/specs/deep-assign.spec.js diff --git a/.github/CONTRIBUTING.zh-CN.md b/.github/CONTRIBUTING.zh-CN.md index 6d481cdd78a..b10f3e3a0a6 100644 --- a/.github/CONTRIBUTING.zh-CN.md +++ b/.github/CONTRIBUTING.zh-CN.md @@ -30,7 +30,7 @@ npm run dev - 仓库的组件代码都位于 `packages` 下,每个组件一个文件夹 - 所有的组件样式代码都位于 `packages/vant-css/src` 下,`vant-css` 也会在发布时单独发包 -- `docs/examples-docs` 目录下是文档网站的代码,根据语言划分为 zh-CN 和 en-US,本地开发时可以在根目录下运行 `npm run dev` 开启文档网站。 +- `docs/markdown` 目录下是文档网站的代码,根据语言划分为 zh-CN 和 en-US,本地开发时可以在根目录下运行 `npm run dev` 开启文档网站。 项目目录大致如下: @@ -58,7 +58,7 @@ vant - 添加文档 -新组件的文档编写,需要在 `docs/examples-docs` 下各个语言中新建对应同名文档 `button.md`,并在 `docs/src/doc.config.js` 中进行文档路径配置 +新组件的文档编写,需要在 `docs/markdown` 下各个语言中新建对应同名文档 `button.md`,在 `docs/demos` 下创建组件示例,并在 `docs/src/doc.config.js` 中进行配置组件名称 - 添加测试代码 @@ -67,7 +67,7 @@ vant ## 组件文档如何编写 -`docs/examples-docs` 下根据语言划分了组件文档,每个组件需要在各语言中编辑对应的文档。组件文档采用 markdown 格式,内容包括使用示例以及 `API` 等。具体书写规范请参考 [组件文档书写规范](./MARKDOWN.md)。 +`docs/markdown` 下根据语言划分了组件文档,每个组件需要在各语言中编辑对应的文档。组件文档采用 markdown 格式,内容包括使用示例以及 `API` 等。具体书写规范请参考 [组件文档书写规范](./MARKDOWN.md)。 #### API 说明 @@ -106,5 +106,5 @@ vant `z-index` 优先级(从高到低): * 特殊组件:Toast 永远在最上面,[3000, +∞) -* ‘用完就关’ 的组件:Dialog, Pop, Actionsheet, image-preview 等 [2000, 3000) +* ‘用完就关’ 的组件:Dialog, Pop, Actionsheet, ImagePreview 等 [2000, 3000) * 其他:组件内部用来控制层次的 z-index 的区间 [-10, 10],尽可能写小,一般1,2,3这种就够了。 diff --git a/.github/MARKDOWN.md b/.github/MARKDOWN.md index 96ded0eb44b..ade817155cb 100644 --- a/.github/MARKDOWN.md +++ b/.github/MARKDOWN.md @@ -18,28 +18,24 @@ #### 代码演示 -另起一个二级标题,正文可以是 markdown 和示例的混合。示例的结构如下: - - // 在 demo 端之外放置的 script 会直接运行 - // 在 script 中声明的 vue 变量,在 demo 中都可以直接使用 - +另起一个二级标题,示例的结构如下: + + ```javascript + export default { + data() { + return { + size: 'large' + }; + } + }; + ``` + + ```html + + Large + + ``` - :::demo 基础用法(必须以:::demo开头,后面的描述可选,如果有的话控制在一两句话,不要过长) - ```html // :::demo后面必须接代码段,否则不会识别为示例 - // 在内容区直接写 vue 中 template 段代码即可 - Large - - ``` - ::: // 示例结束的标记,必须接在代码段之后,否则不会识别为示例 - 代码演示的几个书写原则: - 从简单用法开始介绍,不要上来就同时使用一大堆 API,会让人觉得难以上手 diff --git a/build/bin/build-entry.js b/build/bin/build-entry.js index 27c7b9e96e4..9877586a093 100644 --- a/build/bin/build-entry.js +++ b/build/bin/build-entry.js @@ -1,28 +1,37 @@ -var Components = require('./get-components')(); -var fs = require('fs'); -var render = require('json-templater/string'); -var uppercamelcase = require('uppercamelcase'); -var path = require('path'); - -var OUTPUT_PATH = path.join(__dirname, '../../packages/index.js'); -var IMPORT_TEMPLATE = 'import {{name}} from \'./{{package}}\';'; -var ISNTALL_COMPONENT_TEMPLATE = ' {{name}}'; -var MAIN_TEMPLATE = `{{include}} - -const version = '{{version}}'; +const Components = require('./get-components')(); +const fs = require('fs'); +const path = require('path'); +const uppercamelize = require('uppercamelcase'); +const version = process.env.VERSION || require('../../package.json').version; +const tips = '// This file is auto gererated by build/bin/build-entry.js'; + +function buildVantEntry() { + const uninstallComponents = [ + 'Lazyload', + 'Waterfall', + 'Dialog', + 'Toast', + 'ImagePreview', + 'Locale' + ]; + + const importList = Components.map(name => `import ${uppercamelize(name)} from './${name}';`); + const exportList = Components.map(name => `${uppercamelize(name)}`); + const intallList = exportList.filter(name => !~uninstallComponents.indexOf(uppercamelize(name))); + const content = `${tips} +${importList.join('\n')} + +const version = '${version}'; const components = [ -{{components}} + ${intallList.join(',\n ')} ]; -const install = function(Vue) { - if (install.installed) return; - +const install = Vue => { components.forEach(component => { Vue.component(component.name, component); }); }; -/* istanbul ignore if */ if (typeof window !== 'undefined' && window.Vue) { install(window.Vue); } @@ -30,54 +39,72 @@ if (typeof window !== 'undefined' && window.Vue) { export { install, version, -{{list}} + ${exportList.join(',\n ')} }; + export default { install, version }; `; -delete Components.font; + fs.writeFileSync(path.join(__dirname, '../../packages/index.js'), content); +} -var includeComponentTemplate = []; -var installTemplate = []; -var listTemplate = []; +function buildDemoEntry() { + const dir = path.join(__dirname, '../../docs/demos/views'); + const demos = fs.readdirSync(dir) + .filter(name => ~name.indexOf('.vue')) + .map(name => name.replace('.vue', '')) + .map(name => `'${name}': r => require.ensure([], () => r(wrapper(require('./views/${name}'), '${name}')), '${name}')`); -Components.forEach(name => { - var componentName = uppercamelcase(name); + const content = `${tips} +import './common'; - includeComponentTemplate.push(render(IMPORT_TEMPLATE, { - name: componentName, - package: name - })); +function wrapper(component, name) { + component = component.default; + component.name = 'demo-' + name; + return component; +} - if ([ - // directives - 'Lazyload', - 'Waterfall', +export default { + ${demos.join(',\n ')} +}; +`; + fs.writeFileSync(path.join(dir, '../index.js'), content); +} - // services - 'Dialog', - 'Toast', - 'ImagePreview' - ].indexOf(componentName) === -1) { - installTemplate.push(render(ISNTALL_COMPONENT_TEMPLATE, { - name: componentName, - component: name - })); - } - - listTemplate.push(` ${componentName}`); -}); - -var template = render(MAIN_TEMPLATE, { - include: includeComponentTemplate.join('\n'), - list: listTemplate.join(',\n'), - components: installTemplate.join(',\n') || ' ', - version: process.env.VERSION || require('../../package.json').version -}); - -fs.writeFileSync(OUTPUT_PATH, template); -console.log('[build entry] DONE:' + OUTPUT_PATH); +function buildDocsEntry() { + const dir = path.join(__dirname, '../../docs/markdown'); + const cnDocs = fs.readdirSync(path.join(dir, 'zh-CN')).map(name => 'zh-CN/' + name); + const enDocs = fs.readdirSync(path.join(dir, 'en-US')).map(name => 'en-US/' + name); + const docs = [...cnDocs, ...enDocs] + .filter(name => name.indexOf('.md') !== -1) + .map(name => name.replace('.md', '')) + .map(name => `'${name}': wrapper(r => require.ensure([], () => r(require('./${name}.md')), '${name}'))`); + + const content = `${tips} +import progress from 'nprogress'; +import 'nprogress/nprogress.css'; + +function wrapper(component) { + return function(r) { + progress.start(); + component(r).then(() => { + progress.done(); + }).catch(() => { + progress.done(); + }); + }; +} + +export default { + ${docs.join(',\n ')} +}; +`; + fs.writeFileSync(path.join(dir, './index.js'), content); +} +buildVantEntry(); +buildDemoEntry(); +buildDocsEntry(); diff --git a/build/webpack.config.dev.js b/build/webpack.config.dev.js index 1ecb1ab437c..9d344221b1c 100644 --- a/build/webpack.config.dev.js +++ b/build/webpack.config.dev.js @@ -6,20 +6,11 @@ const ProgressBarPlugin = require('progress-bar-webpack-plugin'); const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin'); const isProduction = process.env.NODE_ENV === 'production'; const docConfig = require('../docs/src/doc.config'); -const { extractExample } = require('zan-doc/src/helper'); const styleLoaders = [ { loader: 'css-loader' }, { loader: 'postcss-loader', options: { sourceMap: true } } ]; -// extract [components].vue from [components].md -extractExample({ - src: path.resolve(__dirname, '../docs/examples-docs'), - dist: path.resolve(__dirname, '../docs/examples-dist'), - nav: docConfig, - watch: !isProduction -}); - module.exports = { entry: { vendor: ['packages'], @@ -89,15 +80,7 @@ module.exports = { test: /\.md/, loader: 'vue-markdown-loader', options: { - preventExtract: true, - use: [[require('markdown-it-container'), 'demo']], - preprocess(MarkdownIt, source) { - const styleRegexp = /)<[^<]*)*<\/style>/i; - const scriptRegexp = /)<[^<]*)*<\/script>/i; - MarkdownIt.renderer.rules.table_open = () => - ''; - return source.replace(styleRegexp, '').replace(scriptRegexp, ''); - } + preventExtract: true } }, { diff --git a/docs/demos/common.js b/docs/demos/common.js new file mode 100644 index 00000000000..a3446c2a2e5 --- /dev/null +++ b/docs/demos/common.js @@ -0,0 +1,72 @@ +/** + * Demo Common Mixin && i18n + */ + +import Vue from 'vue'; +import { Locale, Toast, Dialog } from 'packages'; +import { DemoBlock, DemoSection } from 'vant-doc'; +import camelize from 'packages/utils/camelize'; + +const demoBaseMixin = { + beforeCreate() { + const { name, i18n } = this.$options; + if (name && i18n) { + const formattedI18n = {}; + const camelizedName = camelize(name); + Object.keys(i18n).forEach(key => { + formattedI18n[key] = { [camelizedName]: i18n[key] }; + }); + Locale.add(formattedI18n); + } + } +}; + +window.Toast = Toast; +window.Dialog = Dialog; +Vue.mixin(Locale.i18n); +Vue.mixin(demoBaseMixin); +Vue.component('demo-block', DemoBlock); +Vue.component('demo-section', DemoSection); + +Locale.add({ + 'zh-CN': { + red: '红色', + orange: '橙色', + yellow: '黄色', + tab: '标签', + tag: '标签', + desc: '描述信息', + back: '返回', + title: '标题', + status: '状态', + button: '按钮', + option: '选项', + search: '搜索', + content: '内容', + custom: '自定义', + loading: '加载状态', + disabled: '禁用状态', + basicUsage: '基础用法', + advancedUsage: '高级用法' + }, + 'en-US': { + red: 'Red', + orange: 'Orange', + yellow: 'Yellow', + tab: 'Tab', + tag: 'Tag', + desc: 'Description', + back: 'Back', + title: 'Title', + status: 'Status', + button: 'Button', + option: 'Option', + search: 'Search', + content: 'Content', + custom: 'Custom', + loading: 'Loading', + disabled: 'Disabled', + basicUsage: 'Basic Usage', + advancedUsage: 'Advanced Usage' + } +}); diff --git a/docs/demos/index.js b/docs/demos/index.js new file mode 100644 index 00000000000..c4fdad34567 --- /dev/null +++ b/docs/demos/index.js @@ -0,0 +1,57 @@ +// This file is auto gererated by build/bin/build-entry.js +import './common'; + +function wrapper(component, name) { + component = component.default; + component.name = 'demo-' + name; + return component; +} + +export default { + 'actionsheet': r => require.ensure([], () => r(wrapper(require('./views/actionsheet'), 'actionsheet')), 'actionsheet'), + 'address-edit': r => require.ensure([], () => r(wrapper(require('./views/address-edit'), 'address-edit')), 'address-edit'), + 'address-list': r => require.ensure([], () => r(wrapper(require('./views/address-list'), 'address-list')), 'address-list'), + 'area': r => require.ensure([], () => r(wrapper(require('./views/area'), 'area')), 'area'), + 'badge': r => require.ensure([], () => r(wrapper(require('./views/badge'), 'badge')), 'badge'), + 'button': r => require.ensure([], () => r(wrapper(require('./views/button'), 'button')), 'button'), + 'card': r => require.ensure([], () => r(wrapper(require('./views/card'), 'card')), 'card'), + 'cell-swipe': r => require.ensure([], () => r(wrapper(require('./views/cell-swipe'), 'cell-swipe')), 'cell-swipe'), + 'cell': r => require.ensure([], () => r(wrapper(require('./views/cell'), 'cell')), 'cell'), + 'checkbox': r => require.ensure([], () => r(wrapper(require('./views/checkbox'), 'checkbox')), 'checkbox'), + 'contact': r => require.ensure([], () => r(wrapper(require('./views/contact'), 'contact')), 'contact'), + 'coupon': r => require.ensure([], () => r(wrapper(require('./views/coupon'), 'coupon')), 'coupon'), + 'datetime-picker': r => require.ensure([], () => r(wrapper(require('./views/datetime-picker'), 'datetime-picker')), 'datetime-picker'), + 'dialog': r => require.ensure([], () => r(wrapper(require('./views/dialog'), 'dialog')), 'dialog'), + 'field': r => require.ensure([], () => r(wrapper(require('./views/field'), 'field')), 'field'), + 'goods-action': r => require.ensure([], () => r(wrapper(require('./views/goods-action'), 'goods-action')), 'goods-action'), + 'icon': r => require.ensure([], () => r(wrapper(require('./views/icon'), 'icon')), 'icon'), + 'image-preview': r => require.ensure([], () => r(wrapper(require('./views/image-preview'), 'image-preview')), 'image-preview'), + 'layout': r => require.ensure([], () => r(wrapper(require('./views/layout'), 'layout')), 'layout'), + 'lazyload': r => require.ensure([], () => r(wrapper(require('./views/lazyload'), 'lazyload')), 'lazyload'), + 'loading': r => require.ensure([], () => r(wrapper(require('./views/loading'), 'loading')), 'loading'), + 'nav-bar': r => require.ensure([], () => r(wrapper(require('./views/nav-bar'), 'nav-bar')), 'nav-bar'), + 'notice-bar': r => require.ensure([], () => r(wrapper(require('./views/notice-bar'), 'notice-bar')), 'notice-bar'), + 'number-keyboard': r => require.ensure([], () => r(wrapper(require('./views/number-keyboard'), 'number-keyboard')), 'number-keyboard'), + 'panel': r => require.ensure([], () => r(wrapper(require('./views/panel'), 'panel')), 'panel'), + 'password-input': r => require.ensure([], () => r(wrapper(require('./views/password-input'), 'password-input')), 'password-input'), + 'picker': r => require.ensure([], () => r(wrapper(require('./views/picker'), 'picker')), 'picker'), + 'popup': r => require.ensure([], () => r(wrapper(require('./views/popup'), 'popup')), 'popup'), + 'progress': r => require.ensure([], () => r(wrapper(require('./views/progress'), 'progress')), 'progress'), + 'pull-refresh': r => require.ensure([], () => r(wrapper(require('./views/pull-refresh'), 'pull-refresh')), 'pull-refresh'), + 'radio': r => require.ensure([], () => r(wrapper(require('./views/radio'), 'radio')), 'radio'), + 'search': r => require.ensure([], () => r(wrapper(require('./views/search'), 'search')), 'search'), + 'sku': r => require.ensure([], () => r(wrapper(require('./views/sku'), 'sku')), 'sku'), + 'stepper': r => require.ensure([], () => r(wrapper(require('./views/stepper'), 'stepper')), 'stepper'), + 'steps': r => require.ensure([], () => r(wrapper(require('./views/steps'), 'steps')), 'steps'), + 'submit-bar': r => require.ensure([], () => r(wrapper(require('./views/submit-bar'), 'submit-bar')), 'submit-bar'), + 'swipe': r => require.ensure([], () => r(wrapper(require('./views/swipe'), 'swipe')), 'swipe'), + 'switch-cell': r => require.ensure([], () => r(wrapper(require('./views/switch-cell'), 'switch-cell')), 'switch-cell'), + 'switch': r => require.ensure([], () => r(wrapper(require('./views/switch'), 'switch')), 'switch'), + 'tab': r => require.ensure([], () => r(wrapper(require('./views/tab'), 'tab')), 'tab'), + 'tabbar': r => require.ensure([], () => r(wrapper(require('./views/tabbar'), 'tabbar')), 'tabbar'), + 'tag': r => require.ensure([], () => r(wrapper(require('./views/tag'), 'tag')), 'tag'), + 'toast': r => require.ensure([], () => r(wrapper(require('./views/toast'), 'toast')), 'toast'), + 'tree-select': r => require.ensure([], () => r(wrapper(require('./views/tree-select'), 'tree-select')), 'tree-select'), + 'uploader': r => require.ensure([], () => r(wrapper(require('./views/uploader'), 'uploader')), 'uploader'), + 'waterfall': r => require.ensure([], () => r(wrapper(require('./views/waterfall'), 'waterfall')), 'waterfall') +}; diff --git a/docs/mock/area.json b/docs/demos/mock/area.json similarity index 100% rename from docs/mock/area.json rename to docs/demos/mock/area.json diff --git a/docs/mock/sku.js b/docs/demos/mock/sku.js similarity index 100% rename from docs/mock/sku.js rename to docs/demos/mock/sku.js diff --git a/docs/demos/views/actionsheet.vue b/docs/demos/views/actionsheet.vue new file mode 100644 index 00000000000..46e9aabf408 --- /dev/null +++ b/docs/demos/views/actionsheet.vue @@ -0,0 +1,81 @@ + + + + + diff --git a/docs/demos/views/address-edit.vue b/docs/demos/views/address-edit.vue new file mode 100644 index 00000000000..0e2e9e55c72 --- /dev/null +++ b/docs/demos/views/address-edit.vue @@ -0,0 +1,69 @@ + + + + + + diff --git a/docs/demos/views/address-list.vue b/docs/demos/views/address-list.vue new file mode 100644 index 00000000000..c6d56deb5e8 --- /dev/null +++ b/docs/demos/views/address-list.vue @@ -0,0 +1,60 @@ + + + diff --git a/docs/demos/views/area.vue b/docs/demos/views/area.vue new file mode 100644 index 00000000000..35bd296d96d --- /dev/null +++ b/docs/demos/views/area.vue @@ -0,0 +1,38 @@ + + + diff --git a/docs/demos/views/badge.vue b/docs/demos/views/badge.vue new file mode 100644 index 00000000000..308c35e1a67 --- /dev/null +++ b/docs/demos/views/badge.vue @@ -0,0 +1,54 @@ + + + + + diff --git a/docs/demos/views/button.vue b/docs/demos/views/button.vue new file mode 100644 index 00000000000..7705533396b --- /dev/null +++ b/docs/demos/views/button.vue @@ -0,0 +1,92 @@ + + + + + + \ No newline at end of file diff --git a/docs/demos/views/card.vue b/docs/demos/views/card.vue new file mode 100644 index 00000000000..09892340ce5 --- /dev/null +++ b/docs/demos/views/card.vue @@ -0,0 +1,38 @@ + + + diff --git a/docs/demos/views/cell-swipe.vue b/docs/demos/views/cell-swipe.vue new file mode 100644 index 00000000000..c12a759ef8c --- /dev/null +++ b/docs/demos/views/cell-swipe.vue @@ -0,0 +1,51 @@ + + + + + diff --git a/docs/demos/views/cell.vue b/docs/demos/views/cell.vue new file mode 100644 index 00000000000..8e4a3c9b893 --- /dev/null +++ b/docs/demos/views/cell.vue @@ -0,0 +1,86 @@ + + + + + \ No newline at end of file diff --git a/docs/demos/views/checkbox.vue b/docs/demos/views/checkbox.vue new file mode 100644 index 00000000000..8ad87952af3 --- /dev/null +++ b/docs/demos/views/checkbox.vue @@ -0,0 +1,77 @@ + + + + + diff --git a/docs/demos/views/contact.vue b/docs/demos/views/contact.vue new file mode 100644 index 00000000000..0c17b6a0da2 --- /dev/null +++ b/docs/demos/views/contact.vue @@ -0,0 +1,116 @@ + + + + + diff --git a/docs/demos/views/coupon.vue b/docs/demos/views/coupon.vue new file mode 100644 index 00000000000..698d06e4a5d --- /dev/null +++ b/docs/demos/views/coupon.vue @@ -0,0 +1,96 @@ + + + + + diff --git a/docs/demos/views/datetime-picker.vue b/docs/demos/views/datetime-picker.vue new file mode 100644 index 00000000000..8cbe3b61f6e --- /dev/null +++ b/docs/demos/views/datetime-picker.vue @@ -0,0 +1,61 @@ + + + diff --git a/docs/demos/views/dialog.vue b/docs/demos/views/dialog.vue new file mode 100644 index 00000000000..2f16fafe0ea --- /dev/null +++ b/docs/demos/views/dialog.vue @@ -0,0 +1,60 @@ + + + + + + diff --git a/docs/demos/views/field.vue b/docs/demos/views/field.vue new file mode 100644 index 00000000000..f0c78ea4627 --- /dev/null +++ b/docs/demos/views/field.vue @@ -0,0 +1,105 @@ + + + + + diff --git a/docs/demos/views/goods-action.vue b/docs/demos/views/goods-action.vue new file mode 100644 index 00000000000..c8a35efd377 --- /dev/null +++ b/docs/demos/views/goods-action.vue @@ -0,0 +1,52 @@ + + + + + + diff --git a/docs/examples-docs/en-US/icon.md b/docs/demos/views/icon.vue similarity index 57% rename from docs/examples-docs/en-US/icon.md rename to docs/demos/views/icon.vue index de385509371..77e460683f3 100644 --- a/docs/examples-docs/en-US/icon.md +++ b/docs/demos/views/icon.vue @@ -1,6 +1,15 @@ - -## Icon - -### Install -``` javascript -import { Icon } from 'vant'; + diff --git a/docs/demos/views/image-preview.vue b/docs/demos/views/image-preview.vue new file mode 100644 index 00000000000..7e81eed84e3 --- /dev/null +++ b/docs/demos/views/image-preview.vue @@ -0,0 +1,51 @@ + + + + + \ No newline at end of file diff --git a/docs/demos/views/layout.vue b/docs/demos/views/layout.vue new file mode 100644 index 00000000000..ad45033744b --- /dev/null +++ b/docs/demos/views/layout.vue @@ -0,0 +1,65 @@ + + + + + \ No newline at end of file diff --git a/docs/demos/views/lazyload.vue b/docs/demos/views/lazyload.vue new file mode 100644 index 00000000000..9a8a96fb7c1 --- /dev/null +++ b/docs/demos/views/lazyload.vue @@ -0,0 +1,82 @@ + + + + + \ No newline at end of file diff --git a/docs/demos/views/loading.vue b/docs/demos/views/loading.vue new file mode 100644 index 00000000000..2ce588f235d --- /dev/null +++ b/docs/demos/views/loading.vue @@ -0,0 +1,44 @@ + + + + + diff --git a/docs/demos/views/nav-bar.vue b/docs/demos/views/nav-bar.vue new file mode 100644 index 00000000000..adc2f58f5ff --- /dev/null +++ b/docs/demos/views/nav-bar.vue @@ -0,0 +1,18 @@ + diff --git a/docs/demos/views/notice-bar.vue b/docs/demos/views/notice-bar.vue new file mode 100644 index 00000000000..e37e3da34e0 --- /dev/null +++ b/docs/demos/views/notice-bar.vue @@ -0,0 +1,44 @@ + + + + + \ No newline at end of file diff --git a/docs/demos/views/number-keyboard.vue b/docs/demos/views/number-keyboard.vue new file mode 100644 index 00000000000..ed050986978 --- /dev/null +++ b/docs/demos/views/number-keyboard.vue @@ -0,0 +1,59 @@ + + + + + + diff --git a/docs/demos/views/panel.vue b/docs/demos/views/panel.vue new file mode 100644 index 00000000000..86cbdea15c4 --- /dev/null +++ b/docs/demos/views/panel.vue @@ -0,0 +1,35 @@ + + + \ No newline at end of file diff --git a/docs/demos/views/password-input.vue b/docs/demos/views/password-input.vue new file mode 100644 index 00000000000..e5781f42480 --- /dev/null +++ b/docs/demos/views/password-input.vue @@ -0,0 +1,47 @@ + + + diff --git a/docs/demos/views/picker.vue b/docs/demos/views/picker.vue new file mode 100644 index 00000000000..e9006595a82 --- /dev/null +++ b/docs/demos/views/picker.vue @@ -0,0 +1,74 @@ + + + + + + diff --git a/docs/demos/views/popup.vue b/docs/demos/views/popup.vue new file mode 100644 index 00000000000..25ca51d8925 --- /dev/null +++ b/docs/demos/views/popup.vue @@ -0,0 +1,112 @@ + + + + + \ No newline at end of file diff --git a/docs/demos/views/progress.vue b/docs/demos/views/progress.vue new file mode 100644 index 00000000000..5ab05dd8d58 --- /dev/null +++ b/docs/demos/views/progress.vue @@ -0,0 +1,48 @@ + + + + + \ No newline at end of file diff --git a/docs/demos/views/pull-refresh.vue b/docs/demos/views/pull-refresh.vue new file mode 100644 index 00000000000..0b3084eade5 --- /dev/null +++ b/docs/demos/views/pull-refresh.vue @@ -0,0 +1,49 @@ + + + + + diff --git a/docs/demos/views/radio.vue b/docs/demos/views/radio.vue new file mode 100644 index 00000000000..00e242c85b6 --- /dev/null +++ b/docs/demos/views/radio.vue @@ -0,0 +1,77 @@ + + + + + diff --git a/docs/demos/views/search.vue b/docs/demos/views/search.vue new file mode 100644 index 00000000000..deb9c4aa234 --- /dev/null +++ b/docs/demos/views/search.vue @@ -0,0 +1,68 @@ + + + + + \ No newline at end of file diff --git a/docs/demos/views/sku.vue b/docs/demos/views/sku.vue new file mode 100644 index 00000000000..763ae13ca5c --- /dev/null +++ b/docs/demos/views/sku.vue @@ -0,0 +1,115 @@ + + + + + diff --git a/docs/demos/views/stepper.vue b/docs/demos/views/stepper.vue new file mode 100644 index 00000000000..2890c278841 --- /dev/null +++ b/docs/demos/views/stepper.vue @@ -0,0 +1,34 @@ + + + + + \ No newline at end of file diff --git a/docs/demos/views/steps.vue b/docs/demos/views/steps.vue new file mode 100644 index 00000000000..c2dbe60895e --- /dev/null +++ b/docs/demos/views/steps.vue @@ -0,0 +1,113 @@ + + + + + \ No newline at end of file diff --git a/docs/demos/views/submit-bar.vue b/docs/demos/views/submit-bar.vue new file mode 100644 index 00000000000..335c8636bb1 --- /dev/null +++ b/docs/demos/views/submit-bar.vue @@ -0,0 +1,76 @@ + + + + + diff --git a/docs/demos/views/swipe.vue b/docs/demos/views/swipe.vue new file mode 100644 index 00000000000..aafe3614702 --- /dev/null +++ b/docs/demos/views/swipe.vue @@ -0,0 +1,80 @@ + + + + + \ No newline at end of file diff --git a/docs/demos/views/switch-cell.vue b/docs/demos/views/switch-cell.vue new file mode 100644 index 00000000000..264901030f1 --- /dev/null +++ b/docs/demos/views/switch-cell.vue @@ -0,0 +1,45 @@ + + + + + + diff --git a/docs/demos/views/switch.vue b/docs/demos/views/switch.vue new file mode 100644 index 00000000000..da24b2206ac --- /dev/null +++ b/docs/demos/views/switch.vue @@ -0,0 +1,61 @@ + + + + + + diff --git a/docs/demos/views/tab.vue b/docs/demos/views/tab.vue new file mode 100644 index 00000000000..41d3da68bb1 --- /dev/null +++ b/docs/demos/views/tab.vue @@ -0,0 +1,112 @@ + + + + + diff --git a/docs/demos/views/tabbar.vue b/docs/demos/views/tabbar.vue new file mode 100644 index 00000000000..33b55c3b7be --- /dev/null +++ b/docs/demos/views/tabbar.vue @@ -0,0 +1,60 @@ + + + + + + diff --git a/docs/demos/views/tag.vue b/docs/demos/views/tag.vue new file mode 100644 index 00000000000..85999b0ff38 --- /dev/null +++ b/docs/demos/views/tag.vue @@ -0,0 +1,53 @@ + + + + + diff --git a/docs/demos/views/toast.vue b/docs/demos/views/toast.vue new file mode 100644 index 00000000000..61d58208f84 --- /dev/null +++ b/docs/demos/views/toast.vue @@ -0,0 +1,95 @@ + + + + + + diff --git a/docs/demos/views/tree-select.vue b/docs/demos/views/tree-select.vue new file mode 100644 index 00000000000..3cfcc256681 --- /dev/null +++ b/docs/demos/views/tree-select.vue @@ -0,0 +1,119 @@ + + + + + + diff --git a/docs/demos/views/uploader.vue b/docs/demos/views/uploader.vue new file mode 100644 index 00000000000..15b972f1571 --- /dev/null +++ b/docs/demos/views/uploader.vue @@ -0,0 +1,31 @@ + + + + + + diff --git a/docs/demos/views/waterfall.vue b/docs/demos/views/waterfall.vue new file mode 100644 index 00000000000..965895c3a7d --- /dev/null +++ b/docs/demos/views/waterfall.vue @@ -0,0 +1,77 @@ + + + + + + diff --git a/docs/examples-docs/en-US/dialog.md b/docs/examples-docs/en-US/dialog.md deleted file mode 100644 index 97f8d5ac64a..00000000000 --- a/docs/examples-docs/en-US/dialog.md +++ /dev/null @@ -1,126 +0,0 @@ - - -## Dialog - -### Install - -```js -import { Dialog } from 'vant'; -``` - -### Usage - -#### Alert dialog -Used to prompt for some messages, only including one confirm button - -:::demo Alert dialog -```html -Alert -Alert without title -``` - -```javascript -export default { - methods: { - onClickAlert() { - Dialog.alert({ - title: 'Title', - message: 'Content' - }).then(() => { - // on close - }); - }, - - onClickAlert2() { - Dialog.alert({ - message: 'Content' - }).then(() => { - // on close - }); - } - } -}; -``` -::: - -#### Confirm dialog -Used to confirm some messages, including a confirm button and a cancel button - -:::demo Confirm dialog -```html -Confirm -``` - -```javascript -export default { - methods: { - onClickConfirm() { - Dialog.confirm({ - title: 'Title', - message: 'Content' - }).then(() => { - // on confirm - }).catch(() => { - // on cancel - }); - } - } -}; -``` -::: - -### Methods - -| Name | Attribute | Return value | Description | -|-----------|-----------|-----------|-------------| -| Dialog.alert | options | `Promise` | Show alert dialog | -| Dialog.confirm | options | `Promise` | Show confim dialog | -| Dialog.close | - | `void` | Close dialog | - -### Options - -| Attribute | Description | Type | Default | Accepted Values | -|-----------|-----------|-----------|-------------|-------------| -| title | Title | `String` | - | - | -| message | Message | `String` | - | - | -| showConfirmButton | Whether to show confirm button | `Boolean` | `true` | - | -| showCancelButton | Whether to show cancel button | `Boolean` | `false` | - | -| confirmButtonText | Confirm button text | `String` | `确认` | - | -| cancelButtonText | Cancel button test | `String` | `取消` | - | -| overlay | Whether to show overlay | `Boolean` | `true` | - | -| closeOnClickOverlay | Whether to close when click overlay | `Boolean` | `false` | - | -| lockOnScroll | Whether to lock body scroll | `Boolean` | `true` | - | diff --git a/docs/examples-docs/en-US/image-preview.md b/docs/examples-docs/en-US/image-preview.md deleted file mode 100644 index 57f01108045..00000000000 --- a/docs/examples-docs/en-US/image-preview.md +++ /dev/null @@ -1,52 +0,0 @@ - - -## ImagePreview - -### Install - -```js -import { ImagePreview } from 'vant'; -``` - -### Usage - -#### Basic Usage - -:::demo Basic Usage -```html -Show -``` - -```javascript -export default { - methods: { - showImagePreview() { - ImagePreview([ - 'https://img.yzcdn.cn/1.jpg', - 'https://img.yzcdn.cn/2.jpg' - ]); - } - } -}; -``` -::: - -### Arguments - -| Attribute | Description | Type | -|-----------|-----------|-----------| -| imageUrls | Image URL list | `Array` | diff --git a/docs/examples-docs/en-US/popup.md b/docs/examples-docs/en-US/popup.md deleted file mode 100644 index 0c3e4215804..00000000000 --- a/docs/examples-docs/en-US/popup.md +++ /dev/null @@ -1,119 +0,0 @@ - - -## Popup - -### Install -``` javascript -import { Popup } from 'vant'; - -Vue.component(Popup.name, Popup); -``` - -### Usage - -#### Basic Usage -Popup is located in the middle of the screen by default - -:::demo Basic Usage -```html -Show Popup -Content -``` - -```javascript -export default { - data() { - return { - show1: false - } - } -}; -``` -::: - -#### Different Position -Use `position` prop to set popup display position - -:::demo Different Position -```html -From Bottom - - Show Dialog - - -From Top -Content - -From Right - - Close - -``` - -```javascript -export default { - data() { - return { - show1: false, - show2: false, - show3: false, - show4: false - } - }, - - watch: { - show2(val) { - if (val) { - setTimeout(() => { - this.show2 = false; - }, 2000); - } - } - } -}; -``` -::: - -### API - -| Attribute | Description | Type | Default | Accepted Values | -|-----------|-----------|-----------|-------------|-------------| -| v-model | Whether to show popup | `Boolean` | `false` | - | -| overlay | Whether to show overlay | `Boolean` | `true` | - | -| lockOnScroll | Lock body scroll | `Boolean` | `false` | - | -| position | Position | `String` | - | `top` `bottom` `right` `left` | -| closeOnClickOverlay | Close popup when click overlay | `Boolean` | `true` | - | -| transition | Transition | `String` | `popup-slide` | - | -| preventScroll | Prevent background scroll | `Boolean` | `false` | - | diff --git a/docs/examples-docs/en-US/tab.md b/docs/examples-docs/en-US/tab.md deleted file mode 100644 index bfa597b0a63..00000000000 --- a/docs/examples-docs/en-US/tab.md +++ /dev/null @@ -1,339 +0,0 @@ - - - - -## Tabs - -### Install -``` javascript -import { Tab, Tabs } from 'vant'; - -Vue.component(Tab.name, Tab); -Vue.component(Tabs.name, Tabs); -``` - -### Usage - -#### Basic Usage - -By default, the first tab is actived. - -:::demo Basic Usage -```html - - - content of tab 1 - - - content of tab 2 - - - content of tab 3 - - - content of tab 4 - - -``` -::: - -#### Active Specified tab - -You can set `active` attribute on `van-tabs` to active specified tab. - -:::demo Active Specified tab -```html - - - content of tab 1 - - - content of tab 2 - - - content of tab 3 - - - content of tab 4 - - - - -``` -::: - -#### Tab duration time - -You can use `duration` attribute to set tab duration time, the default time is `0.3s`. - -:::demo Tab duration time -```html - - - content of tab 1 - - - content of tab 2 - - - content of tab 3 - - - content of tab 4 - - -``` -::: - -#### Swipe Tabs - -By default more than 4 tabs, you can scroll through the tabs. You can set `swipeThreshold` attribute to customize threshold number. - -:::demo Swipe Tabs -```html - - - content of tab 1 - - - content of tab 2 - - - content of tab 3 - - - content of tab 4 - - - content of tab 5 - - - content of tab 6 - - - content of tab 7 - - - content of tab 8 - - -``` -::: - -#### Disabled Tab - -You can set `disabled` attribute on the corresponding `van-tab`. - -:::demo Disabled Tab -```html - - - content of tab 1 - - - content of tab 2 - - - content of tab 3 - - - content of tab 4 - - -``` - -```javascript -export default { - methods: { - onClickDisabled() { - Toast('Disabled!'); - } - } -}; -``` -::: - -#### Card Style - -Tabs styled as cards. - -:::demo Card Style -```html - - - content of tab 1 - - - content of tab 2 - - - content of tab 3 - - - content of tab 4 - - -``` -::: - - -#### Custom Style - -You can set `css class` to customize tabs style. - -:::demo Custom Style -```html - - - content of tab 1 - - - content of tab 2 - - - content of tab 3 - - - content of tab 4 - - - - -``` -::: - -#### Click Event - -You can bind `click` event on `van-tabs`, the event handler function has one parameters: index of click tab. - -:::demo Click Event -```html - - - content of tab 1 - - - content of tab 2 - - - content of tab 3 - - - content of tab 4 - - -``` - -```javascript -export default { - methods: { - handleTabClick(index) { - alert(index); - } - } -}; -``` -::: - -### van-tabs API - -| Attribute | Description | Type | Default | Accepted Values | -|-----------|-----------|-----------|-------------|-------------| -| type | There are two style tabs, set this attribute to change tab style | `String` | `line` | `line`, `card` | -| active | Index of active tab | `String`, `Number` | `0` | - | -| duration | Toggle tab's animation time | `Number` | `0.3` | - | - | -| swipeThreshold | Set swipe tabs threshold | `Number` | `4` | - | - | - -### van-tab API - -| Attribute | Description | Type | Default | Accepted Values | -|-----------|-----------|-----------|-------------|-------------| -| title | Tab title | `String` | - | - | -| disabled | Whether disabled current tab | `Boolean` | `false` | - | - -### van-tabs Event - -| Event | Description | Attribute | -|-----------|-----------|-----------| -| click | Triggered when click tab | index:index of current tab | -| disabled | Triggered when click disabled tab | index:index of current tab | - diff --git a/docs/examples-docs/en-US/toast.md b/docs/examples-docs/en-US/toast.md deleted file mode 100644 index ad04c3db164..00000000000 --- a/docs/examples-docs/en-US/toast.md +++ /dev/null @@ -1,160 +0,0 @@ - - -## Toast - -### Install - -```javascript -import { Toast } from 'vant'; -``` - -### Usage - -#### Text - -:::demo Text -```html -Show Text -``` - -```javascript -export default { - methods: { - showToast() { - Toast('Some messages'); - } - } -} -``` -::: - -#### Loading - -:::demo Loading -```html -Show Loading -``` - -```javascript -export default { - methods: { - showLoadingToast() { - Toast.loading({ mask: true }); - } - } -} -``` -::: - -#### Success/Fail - -:::demo Success/Fail -```html -Show Success -Show Fail -``` - -```javascript -export default { - methods: { - showSuccessToast() { - Toast.success('Success'); - }, - showFailToast() { - Toast.fail('Fail'); - } - } -} -``` -::: - -#### Advanced Usage - -:::demo Advanced Usage -```html -Advanced Usage -``` - -```javascript -export default { - methods: { - showCustomizedToast() { - const toast = Toast.loading({ - duration: 0, // continuous display toast - forbidClick: true, // forbid click background - message: '3 seconds' - }); - - let second = 3; - const timer = setInterval(() => { - second--; - if (second) { - toast.message = `${second} seconds`; - } else { - clearInterval(timer); - Toast.clear(); - } - }, 1000); - } - } -}; -``` -::: - -### Methods - -| Methods | Attribute | Return value | Description | -|-----------|-----------|-----------|-------------| -| Toast | `options | message` | toast instance | Show toast | -| Toast.loading | `options | message` | toast instance | Show loading toast | -| Toast.success | `options | message` | toast instance | Show success toast | -| Toast.fail | `options | message` | toast instance | Show fail toast | -| Toast.clear | - | `void` | Close | - -### Options - -| Attribute | Description | Type | Default | Accepted Values | -|-----------|-----------|-----------|-------------|-------------| -| type | Type | `String` | `text` | `loading` `success` `fail` `html` | -| message | Message | `String` | `''` | - | -| position | Position | `String` | `middle` | `top` `bottom` | -| mask | Whether to show mask | `Boolean` | `false` | - | -| forbidClick | Whether to forbid click background | `Boolean` | `false` | - | -| duration | Toast duration(ms) | `Number` | `3000` | Toast won't disappear if value is 0 | diff --git a/docs/examples-docs/en-US/uploader.md b/docs/examples-docs/en-US/uploader.md deleted file mode 100644 index 635adaf3a68..00000000000 --- a/docs/examples-docs/en-US/uploader.md +++ /dev/null @@ -1,57 +0,0 @@ - - -## Uploader - -### Install -``` javascript -import { Uploader } from 'vant'; - -Vue.component(Uploader.name, Uploader); -``` - -### Usage - -#### Basic Usage - -:::demo Basic Usage -```html -
- - - -
-``` - -```javascript -export default { - methods: { - logContent(file) { - console.log(file) - } - } -}; -``` -::: - -### API - -| Attribute | Description | Type | Default | Accepted Values | -|-----------|-----------|-----------|-------------|-------------| -| resultType | 读取文件的方式,以base64的方式读取;以文本的方式读取 | `String` | `dataUrl` | `text` | -| disable | 是否禁用上传,在图片上传期间设置为true,禁止用户点击此组件上传图片 | `Boolean` | `false` | - | -| beforeRead | 读文件之前的钩子,参数为选择的文件,若返回 false 则停止读取文件 | `Function` | - | - | -| afterRead | 文件读完之后回调此函数,参数为 { file:'选择的文件',content:'读的内容' } | `Function` | - | - | - -### Slot - -| name | Description | -|-----------|-----------| -| - | 自定义上传显示图标 | diff --git a/docs/examples-docs/zh-CN/actionsheet.md b/docs/examples-docs/zh-CN/actionsheet.md deleted file mode 100644 index 7c8af18d4db..00000000000 --- a/docs/examples-docs/zh-CN/actionsheet.md +++ /dev/null @@ -1,181 +0,0 @@ - - - - -## Actionsheet 行动按钮 - -### 使用指南 -``` javascript -import { Actionsheet } from 'vant'; - -Vue.component(Actionsheet.name, Actionsheet); -``` - -### 代码演示 - -#### 基础用法 -需要传入一个`actions`的数组,数组的每一项是一个对象,对象属性见文档下方表格。 - -:::demo 基础用法 -```html -弹出 Actionsheet - -``` - -```javascript -export default { - data() { - return { - show1: false, - actions: [ - { - name: '微信安全支付', - className: 'actionsheet-wx', - callback: this.onClick - }, - { - name: '支付宝支付', - loading: true - }, - { - name: '信用卡支付' - }, - { - name: '其他支付方式' - } - ] - }; - }, - - methods: { - onClick(item) { - Toast(item.name); - } - } -} -``` -::: - -#### 带取消按钮的 Actionsheet - -如果传入了`cancelText`属性,且不为空,则会在下方显示一个取消按钮,点击会将当前`Actionsheet`关闭。 - -:::demo 带取消按钮的 Actionsheet -```html -弹出带取消按钮的 Actionsheet - - -``` - -```javascript -export default { - data() { - return { - show2: false, - actions: [ - { - name: '微信安全支付', - className: 'actionsheet-wx', - callback: this.onClick - }, - { - name: '支付宝支付', - loading: true - }, - { - name: '信用卡支付' - }, - { - name: '其他支付方式' - } - ] - }; - } -} -``` -::: - -#### 带标题的 Actionsheet - -如果传入了`title`属性,且不为空,则另外一种样式的`Actionsheet`,里面内容需要自定义。 - -:::demo 带标题的 Actionsheet -```html -弹出带标题的 Actionsheet - -

一些内容

-
-``` -::: - -### API - -| 参数 | 说明 | 类型 | 默认值 | 可选值 | -|-----------|-----------|-----------|-------------|-------------| -| actions | 行动按钮数组 | `Array` | `[]` | - | -| title | 标题 | `String` | - | - | -| cancelText | 取消按钮文案 | `String` | - | - | -| overlay | 是否显示遮罩 | `Boolean` | - | - | -| closeOnClickOverlay | 点击遮罩是否关闭`Actionsheet` | `Boolean` | - | - | - -### actions - - -`API`中的`actions`为一个对象数组,数组中的每一个对象配置每一列,每一列有以下`key`: - -| key | 说明 | -|-----------|-----------| -| name | 标题 | -| subname | 二级标题 | -| className | 为对应列添加特殊的`class` | -| loading | 是否是`loading`状态 | -| callback | 点击时的回调。该回调接受一个参数,参数为当前点击`action`的对象信息 | diff --git a/docs/examples-docs/zh-CN/dialog.md b/docs/examples-docs/zh-CN/dialog.md deleted file mode 100644 index d549a9169be..00000000000 --- a/docs/examples-docs/zh-CN/dialog.md +++ /dev/null @@ -1,132 +0,0 @@ - - - - -## Dialog 弹出框 - -### 使用指南 - -```js -import { Dialog } from 'vant'; -``` - -### 代码演示 - -#### 消息提示 - -用于提示一些消息,只包含一个确认按钮 - -:::demo 消息提示 -```html -Alert -无标题 Alert -``` - -```javascript -export default { - methods: { - onClickAlert() { - Dialog.alert({ - title: '标题', - message: '弹窗内容' - }).then(() => { - // on close - }); - }, - - onClickAlert2() { - Dialog.alert({ - message: '弹窗内容' - }).then(() => { - // on close - }); - } - } -}; -``` -::: - -#### 消息确认 - -用于确认消息,包含取消和确认按钮 - -:::demo 消息确认 -```html -Confirm -``` - -```javascript -export default { - methods: { - onClickConfirm() { - Dialog.confirm({ - title: '标题', - message: '弹窗内容' - }).then(() => { - // on confirm - }).catch(() => { - // on cancel - }); - } - } -}; -``` -::: - -### 方法 - -| 方法名 | 参数 | 返回值 | 介绍 | -|-----------|-----------|-----------|-------------| -| Dialog.alert | options | `Promise` | 展示消息提示弹窗 | -| Dialog.confirm | options | `Promise` | 展示消息确认弹窗 | -| Dialog.close | - | `void` | 关闭弹窗 | - -### Options - -| 参数 | 说明 | 类型 | 默认值 | 可选值 | -|-----------|-----------|-----------|-------------|-------------| -| title | 标题 | `String` | - | - | -| message | 内容 | `String` | - | - | -| showConfirmButton | 是否展示确认按钮 | `Boolean` | `true` | - | -| showCancelButton | 是否展示取消按钮 | `Boolean` | `false` | - | -| confirmButtonText | 确认按钮的文案 | `String` | `确认` | - | -| cancelButtonText | 取消按钮的文案 | `String` | `取消` | - | -| overlay | 是否展示蒙层 | `Boolean` | `true` | - | -| closeOnClickOverlay | 点击蒙层时是否关闭弹窗 | `Boolean` | `false` | - | -| lockOnScroll | 是否禁用背景滚动 | `Boolean` | `true` | - | diff --git a/docs/examples-docs/zh-CN/icon.md b/docs/examples-docs/zh-CN/icon.md deleted file mode 100644 index 885a9dbcb37..00000000000 --- a/docs/examples-docs/zh-CN/icon.md +++ /dev/null @@ -1,172 +0,0 @@ - - - - -## Icon 图标 - -### 使用指南 -``` javascript -import { Icon } from 'vant'; - -Vue.component(Icon.name, Icon); -``` - -### 代码演示 - -#### 基础用法 - -设置`name`属性为对应的图标名称即可,所有可用的图标名称见右侧列表 -:::demo 图标列表 -```html - -``` -::: - -### API - -| 参数 | 说明 | 类型 | 默认值 | 可选值 | -|-----------|-----------|-----------|-------------|-------------| -| name | icon名称 | `String` | `''` | - | diff --git a/docs/examples-docs/zh-CN/image-preview.md b/docs/examples-docs/zh-CN/image-preview.md deleted file mode 100644 index bc16e3fa4a6..00000000000 --- a/docs/examples-docs/zh-CN/image-preview.md +++ /dev/null @@ -1,89 +0,0 @@ - - - - -## ImagePreview 图片预览 - -### 使用指南 - -`ImagePreview`和其他组件不同,不是通过HTML结构的方式来使用,而是通过函数调用的方式。使用前需要先引入它。 - -```js -import { ImagePreview } from 'vant'; -``` - -### 代码演示 - -#### 基础用法 - -:::demo 基础用法 -```html -预览图片 -``` - -```javascript -export default { - methods: { - showImagePreview() { - ImagePreview([ - 'https://img.yzcdn.cn/1.jpg', - 'https://img.yzcdn.cn/2.jpg' - ]); - } - } -}; -``` -::: - -#### 指定初始位置 - -:::demo 指定初始位置 -```html -指定初始位置 -``` - -```javascript -export default { - methods: { - showImagePreview(startPosition) { - ImagePreview([ - 'https://img.yzcdn.cn/1.jpg', - 'https://img.yzcdn.cn/2.jpg' - ], startPosition); - } - } -}; -``` -::: - -### 方法参数 - -| 参数名 | 说明 | 类型 | -|-----------|-----------|-----------| -| imageUrls | 需要预览的图片 | `Array` | -| startPosition | 图片预览起始位置索引 | `Number` | diff --git a/docs/examples-docs/zh-CN/lazyload.md b/docs/examples-docs/zh-CN/lazyload.md deleted file mode 100644 index 97c266bd973..00000000000 --- a/docs/examples-docs/zh-CN/lazyload.md +++ /dev/null @@ -1,153 +0,0 @@ - - - - -## Lazyload 图片懒加载 - -### 使用指南 - -`Lazyload`是`Vue`指令,所以需要使用它必须将它注册到`Vue`的指令中。 - -```js -import Vue from 'vue'; -import { Lazyload } from 'vant'; - -Vue.use(Lazyload, options); -``` - -### 代码演示 - -#### 基础用法 -将`v-lazy`指令的值设置为你需要懒加载的图片 - -:::demo 基础用法 -```html - -``` - -```javascript -export default { - data() { - return { - imageList: [ - 'https://img.yzcdn.cn/1.jpg', - 'https://img.yzcdn.cn/2.jpg' - ] - }; - } -} -``` -::: - -#### 背景图懒加载 - -和图片懒加载不同,背景图懒加载需要使用`v-lazy:background-image`,值设置为背景图片的地址,需要注意的是必须声明容器高度。 - -:::demo 背景图懒加载 -```html -
-``` - -```javascript -export default { - data() { - return { - backgroundImageList: [ - 'https://img.yzcdn.cn/1.jpg', - 'https://img.yzcdn.cn/2.jpg' - ] - }; - } -} -``` -::: - -#### 懒加载模块 - -懒加载模块需要使用到`lazy-component`,将需要懒加载的内容放在`lazy-component`中即可。 - -:::demo 懒加载模块 -```html - - - -``` - -```javascript -export default { - data() { - return { - componentImageList: [ - 'https://img.yzcdn.cn/1.jpg', - 'https://img.yzcdn.cn/2.jpg' - ] - }; - } -} -``` -::: - -### Options - -| 参数 | 说明 | 类型 | 默认值 | 可选值 | -|-----------|-----------|-----------|-------------|-------------| -| loading | 加载时的图片 | `String` | - | - | -| error | 错误时的图片 | `String` | - | - | -| preload | 预加载高度的比例 | `String` | - | - | -| attempt | 尝试次数 | `Number` | `3` | - | -| listenEvents | 监听的事件 | `Array` | `scroll`等 | - | -| adapter | 适配器 | `Object` | - | - | -| filter | 图片url过滤 | `Object` | - | - | -| lazyComponent | 是否能懒加载模块 | `Boolean` | `false` | - | - -更多内容请参照:[ vue-lazyload 官方文档](https://github.com/hilongjw/vue-lazyload) diff --git a/docs/examples-docs/zh-CN/loading.md b/docs/examples-docs/zh-CN/loading.md deleted file mode 100644 index 1df7f40b961..00000000000 --- a/docs/examples-docs/zh-CN/loading.md +++ /dev/null @@ -1,53 +0,0 @@ - - -## Loading 加载 - -### 使用指南 -``` javascript -import { Loading } from 'vant'; - -Vue.component(Loading.name, Loading); -``` - -### 代码演示 - -#### 单色圆环 - -:::demo 单色圆环 -```html - - -``` -::: - -#### 渐变色圆环 - -:::demo 渐变色圆环 -```html - - -``` -::: - -#### Spinner - -:::demo Spinner -```html - - -``` -::: - -### API - -| 参数 | 说明 | 类型 | 默认值 | 可选值 | -|-----------|-----------|-----------|-------------|-------------| -| color | 颜色 | `String` | `black` | `black` `white` | -| type | 类型 | `String` | `gradient-circle` | `spinner` `circle` | diff --git a/docs/examples-docs/zh-CN/popup.md b/docs/examples-docs/zh-CN/popup.md deleted file mode 100644 index 18772589507..00000000000 --- a/docs/examples-docs/zh-CN/popup.md +++ /dev/null @@ -1,154 +0,0 @@ - - - - -## Popup 弹出层 - -### 使用指南 -``` javascript -import { Popup } from 'vant'; - -Vue.component(Popup.name, Popup); -``` - -### 代码演示 - -#### 基础用法 -`popup`默认从中间弹出 - -:::demo 基础用法 -```html -弹出 Popup -内容 -``` - -```javascript -export default { - data() { - return { - show1: false - } - } -}; -``` -::: - -#### 弹出位置 -通过`position`属性设置 Popup 弹出位置 - -:::demo 弹出位置 -```html -底部弹出 - - 弹出 Dialog - - -顶部弹出 - - 更新成功 - - -右侧弹出 - - 关闭弹层 - -``` - -```javascript -export default { - data() { - return { - show1: false, - show2: false, - show3: false - } - }, - - watch: { - show2(val) { - if (val) { - setTimeout(() => { - this.show2 = false; - }, 2000); - } - } - } -}; -``` -::: - -### API - -| 参数 | 说明 | 类型 | 默认值 | 可选值 | -|-----------|-----------|-----------|-------------|-------------| -| v-model | 当前组件是否显示 | `Boolean` | `false` | - | -| overlay | 是否显示背景遮罩层 | `Boolean` | `true` | - | -| lockOnScroll | 背景是否跟随滚动 | `Boolean` | `false` | - | -| position | 弹出层位置 | `String` | - | `top` `bottom` `right` `left` | -| closeOnClickOverlay | 点击遮罩层是否关闭弹出层 | `Boolean` | `true` | - | -| transition | 弹出层的`transition` | `String` | `popup-slide` | - | -| preventScroll | 是否防止滚动穿透 | `Boolean` | `false` | - | diff --git a/docs/examples-docs/zh-CN/tab.md b/docs/examples-docs/zh-CN/tab.md deleted file mode 100644 index ee4c35a5d6f..00000000000 --- a/docs/examples-docs/zh-CN/tab.md +++ /dev/null @@ -1,257 +0,0 @@ - - - - -## Tabs 标签页 - -### 使用指南 -``` javascript -import { Tab, Tabs } from 'vant'; - -Vue.component(Tab.name, Tab); -Vue.component(Tabs.name, Tabs); -``` - -### 代码演示 - -#### 基础用法 - -默认情况下是启用第一个`tab`。 - -:::demo 基础用法 -```html - - 内容一 - 内容二 - 内容三 - 内容四 - -``` -::: - -#### active特定tab - -可以在`van-tabs`上设置`active`为对应`tab`的索引(从0开始,即0代表第一个)即可激活对应`tab`,默认为0。 - -:::demo 基础用法 -```html - - 内容一 - 内容二 - 内容三 - 内容四 - -``` -::: - -#### 设置切换tab的动画时间 - -通过设置`duration`来指定时间,默认为0.3s,只接受`Number`类型参数。 - -:::demo 设置切换tab的动画时间 -```html - - 内容一 - 内容二 - 内容三 - -``` -::: - -#### 横向滚动tab - -默认情况下多于4个tab时,可以横向滚动tab。可以通过设置`swipeThreshold`这个阙值,多于这个阙值时,tab就会支持横向滚动。 - -:::demo 横向滚动tab -```html - - 内容一 - 内容二 - 内容三 - 内容四 - 内容五 - 内容六 - 内容七 - 内容八 - -``` -::: - -#### 禁用tab - -在对应的`van-tab`上设置`disabled`属性即可。如果需要监听禁用事件,可以在`van-tabs`上监听`disabled`事件。 - -:::demo 禁用tab -```html - - 内容一 - 内容二 - 内容三 - 内容四 - -``` - -```javascript -export default { - methods: { - onClickDisabled() { - Toast('Disabled!') - } - } -}; -``` -::: - -#### card样式 - -`Tabs`目前有两种样式:`line`和`card`,默认为`line`样式,也就上面基础用法中的样式,你可以在`van-tabs`上设置`type`为`card`改为card样式。 - -:::demo card样式 -```html - - 内容一 - 内容二 - 内容三 - 内容四 - -``` -::: - - -#### 自定义样式 - -可以在`van-tabs`上设置对应的`class`,从而自定义某些样式。 - -:::demo 自定义样式 -```html - - 内容一 - 内容二 - 内容三 - 内容四 - - - -``` -::: - -#### click事件 - -可以在`van-tabs`上绑定一个`click`事件,事件处理函数有一个参数,参数为对应`tab`在`tabs`中的索引。 - -:::demo click事件 -```html - - 内容一 - 内容二 - 内容三 - 内容四 - -``` - -```javascript -export default { - methods: { - handleTabClick(index) { - alert(index); - } - } -}; -``` -::: - -### van-tabs API - -| 参数 | 说明 | 类型 | 默认值 | 可选 | -|-----------|-----------|-----------|-------------|-------------| -| type | 两种UI | `String` | `line` | `line`, `card` | -| active | 默认激活的tab | `String`, `Number` | `0` | - | -| duration | 切换tab的动画时间 | `Number` | `0.3` | - | - | -| swipeThreshold | 滚动阀值,默认是超过4个tab时标签页可滚动,通过这个属性可以设置超过多少个可滚动 | `Number` | `4` | - | - | - - -### van-tab API - -| 参数 | 说明 | 类型 | 默认值 | 可选 | -|-----------|-----------|-----------|-------------|-------------| -| title | tab的标题 | `String` | - | - | -| disabled | 是否禁用这个tab | `Boolean` | `false` | - | - -### van-tabs Event - -| 事件名 | 说明 | 参数 | -|-----------|-----------|-----------| -| click | 某个tab点击事件 | index:点击的`tab`的索引 | -| disabled | 某个tab禁用时点击事件 | index:点击的`tab`的索引 | - diff --git a/docs/examples-docs/zh-CN/toast.md b/docs/examples-docs/zh-CN/toast.md deleted file mode 100644 index c251585766a..00000000000 --- a/docs/examples-docs/zh-CN/toast.md +++ /dev/null @@ -1,168 +0,0 @@ - - - - -## Toast 轻提示 - -### 使用指南 - -```javascript -import { Toast } from 'vant'; -``` - -### 代码演示 - -#### 文字提示 - -:::demo 文字提示 -```html -文字提示 -``` - -```javascript -export default { - methods: { - showToast() { - Toast('我是提示文案,建议不超过十五字~'); - } - } -} -``` -::: - -#### 加载提示 - -:::demo 加载提示 -```html -加载提示 -``` - -```javascript -export default { - methods: { - showLoadingToast() { - Toast.loading({ mask: true }); - } - } -} -``` -::: - -#### 成功/失败提示 - -:::demo 成功/失败提示 -```html -成功提示 -失败提示 -``` - -```javascript -export default { - methods: { - showSuccessToast() { - Toast.success('成功文案'); - }, - showFailToast() { - Toast.fail('失败文案'); - } - } -} -``` -::: - -#### 高级用法 - -:::demo 高级用法 -```html -高级用法 -``` - -```javascript -export default { - methods: { - showCustomizedToast() { - const toast = Toast.loading({ - duration: 0, // 持续展示 toast - forbidClick: true, // 禁用背景点击 - message: '倒计时 3 秒' - }); - - let second = 3; - const timer = setInterval(() => { - second--; - if (second) { - toast.message = `倒计时 ${second} 秒`; - } else { - clearInterval(timer); - Toast.clear(); - } - }, 1000); - } - } -}; -``` -::: - -### 方法 - -| 方法名 | 参数 | 返回值 | 介绍 | -|-----------|-----------|-----------|-------------| -| Toast | `options | message` | toast 实例 | 展示提示 | -| Toast.loading | `options | message` | toast 实例 | 展示加载提示 | -| Toast.success | `options | message` | toast 实例 | 展示成功提示 | -| Toast.fail | `options | message` | toast 实例 | 展示失败提示 | -| Toast.clear | - | `void` | 关闭提示 | - -### Options - -| 参数 | 说明 | 类型 | 默认值 | 可选值 | -|-----------|-----------|-----------|-------------|-------------| -| type | 提示类型 | `String` | `text` | `loading` `success` `fail` `html` | -| message | 内容 | `String` | `''` | - | -| position | 位置 | `String` | `middle` | `top` `bottom` | -| mask | 是否显示背景蒙层 | `Boolean` | `false` | - | -| forbidClick | 禁止背景点击 | `Boolean` | `false` | - | -| duration | 时长(ms) | `Number` | `3000` | 值为 0 时,toast 不会消失 | diff --git a/docs/examples-docs/en-US/actionsheet.md b/docs/markdown/en-US/actionsheet.md similarity index 59% rename from docs/examples-docs/en-US/actionsheet.md rename to docs/markdown/en-US/actionsheet.md index 987efa49480..40166334888 100644 --- a/docs/examples-docs/en-US/actionsheet.md +++ b/docs/markdown/en-US/actionsheet.md @@ -1,28 +1,3 @@ - - ## Actionsheet ### Install @@ -37,17 +12,15 @@ Vue.component(Actionsheet.name, Actionsheet); #### Basic Usage Use `actions` prop to set options of actionsheet. -:::demo Basic Usage ```html -Show Actionsheet - + ``` ```javascript export default { data() { return { - show1: false, + show: false, actions: [ { name: 'Option1', callback: this.onClick }, { name: 'Option2' }, @@ -63,28 +36,21 @@ export default { } } ``` -::: #### Actionsheet with cancel button -:::demo Actionsheet with cancel button ```html -Show Actionsheet with cancel button - + ``` -::: #### Actionsheet with title Actionsheet will get another style if there is a `title` prop. -:::demo Actionsheet with title ```html -Show Actionsheet with title - +

Content

``` -::: ### API diff --git a/docs/examples-docs/en-US/address-edit.md b/docs/markdown/en-US/address-edit.md similarity index 75% rename from docs/examples-docs/en-US/address-edit.md rename to docs/markdown/en-US/address-edit.md index b07d00cd4ac..5b7dda5e87d 100644 --- a/docs/examples-docs/en-US/address-edit.md +++ b/docs/markdown/en-US/address-edit.md @@ -1,41 +1,3 @@ - - ## AddressEdit ### Install @@ -49,14 +11,14 @@ Vue.component(AddressEdit.name, AddressEdit); #### Basic Usage -:::demo Basic Usage + ```html -import { Toast } from 'packages'; - -export default { - data() { - return { - chosenAddressId: '1', - list: [ - { - id: '1', - name: '张三', - tel: '13000000000', - address: '浙江省杭州市西湖区文三路 138 号东方通信大厦 7 楼 501 室' - }, - { - id: '2', - name: '李四', - tel: '1310000000', - address: '浙江省杭州市拱墅区莫干山路 50 号' - }, - { - id: '3', - name: '王五', - tel: '1320000000', - address: '浙江省杭州市滨江区江南大道 15 号' - } - ] - } - }, - - methods: { - onAdd() { - Toast('新增收货地址'); - }, - onEdit(item, index) { - Toast('编辑收货地址:' + index); - } - } -} - - ## AddressList ### Install @@ -52,7 +11,6 @@ Vue.component(AddressList.name, AddressList); #### Basic Usage -:::demo Basic Usage ```html -import AreaList from '../../mock/area.json'; - -export default { - data() { - return { - areaList: AreaList - } - } -}; - - ## Area ### Install @@ -26,43 +14,26 @@ Vue.component(Area.name, Area); 要初始化一个`Area`组件,你需要传入一个`areaList`属性,`areaList`Data Structure具体可看下面Data Structure章节。 -:::demo Basic Usage ```html - - - + ``` -::: -#### 选中省市县 +#### Initial Value 如果想选中某个省市县,需要传入一个`value`属性,绑定对应的省市县`code`。 -:::demo 选中省市县 ```html - + ``` -::: -#### 配置显示列 +#### Columns Number 可以通过`columnsNum`属性配置省市县显示的列数,默认情况下会显示省市县,当你设置为`2`,则只会显示省市选择。 -:::demo 配置显示列 ```html - + ``` -::: + ### API @@ -115,7 +86,7 @@ export default { } ``` -完整数据见 [Area.json](https://github.com/youzan/vant/blob/dev/docs/mock/area.json) +完整数据见 [Area.json](https://github.com/youzan/vant/blob/dev/docs/demos/mock/area.json) #### 点击完成时返回的Data Structure 返回的数据整体为一个数组,数组内包含 `columnsNum` 个数据, 每个数据对应一列选项中被选中的数据。 diff --git a/docs/examples-docs/en-US/badge.md b/docs/markdown/en-US/badge.md similarity index 74% rename from docs/examples-docs/en-US/badge.md rename to docs/markdown/en-US/badge.md index 2429ed5c5eb..1c4e56b170e 100644 --- a/docs/examples-docs/en-US/badge.md +++ b/docs/markdown/en-US/badge.md @@ -1,18 +1,3 @@ - - ## Badge ### Install @@ -25,11 +10,10 @@ Vue.component(Badge.name, Badge); ### Usage #### Basic Usage -Use `active-key` prop to set index of chosen 'badge' +Use `activeKey` prop to set index of chosen 'badge' -:::demo Basic Usage ```html - + @@ -51,13 +35,12 @@ export default { } }; ``` -::: ### BadgeGroup API | Attribute | Description | Type | Default | Accepted Values | |-----------|-----------|-----------|-------------|-------------| -| active-key | Index of chosen badge | `String | Number` | `0` | - | +| activeKey | Index of chosen badge | `String | Number` | `0` | - | ### Badge API | Attribute | Description | Type | Default | Accepted Values | diff --git a/docs/examples-docs/en-US/button.md b/docs/markdown/en-US/button.md similarity index 84% rename from docs/examples-docs/en-US/button.md rename to docs/markdown/en-US/button.md index c43fc0b5056..6b111a17301 100644 --- a/docs/examples-docs/en-US/button.md +++ b/docs/markdown/en-US/button.md @@ -11,69 +11,57 @@ Vue.component(Button.name, Button); #### Type -:::demo Type ```html Default Primary Danger ``` -::: #### Size -:::demo Size ```html Large Normal Small Mini ``` -::: #### Disabled -:::demo Disabled ```html Diabled ``` -::: #### Loading -:::demo Loading ```html ``` -::: #### Custom Tag Use `tag` prop to custom button tag -:::demo Custom Tag ```html Button ``` -::: #### Action Button -:::demo Action Button ```html -Text +Button - Text + Button - Text + Button ``` -::: ### API diff --git a/docs/examples-docs/en-US/card.md b/docs/markdown/en-US/card.md similarity index 84% rename from docs/examples-docs/en-US/card.md rename to docs/markdown/en-US/card.md index d16b460fef7..d94c85d71de 100644 --- a/docs/examples-docs/en-US/card.md +++ b/docs/markdown/en-US/card.md @@ -1,13 +1,3 @@ - - ## Card ### Install @@ -21,7 +11,6 @@ Vue.component(Card.name, Card); #### Basic Usage -:::demo Basic Usage ```html ``` -::: #### Advanced Usage Use `slot` to custom content. -:::demo Advanced Usage ```html ``` -::: ### API diff --git a/docs/examples-docs/en-US/cell-swipe.md b/docs/markdown/en-US/cell-swipe.md similarity index 97% rename from docs/examples-docs/en-US/cell-swipe.md rename to docs/markdown/en-US/cell-swipe.md index 6a4f73bd7b2..e54abfa9f19 100644 --- a/docs/examples-docs/en-US/cell-swipe.md +++ b/docs/markdown/en-US/cell-swipe.md @@ -11,7 +11,6 @@ Vue.component(CellSwipe.name, CellSwipe); #### Basic Usage -:::demo Basic Usage ```html Select @@ -21,7 +20,6 @@ Vue.component(CellSwipe.name, CellSwipe); Delete ``` -::: ### API diff --git a/docs/examples-docs/en-US/cell.md b/docs/markdown/en-US/cell.md similarity index 68% rename from docs/examples-docs/en-US/cell.md rename to docs/markdown/en-US/cell.md index 0878fb4e0c9..a57c646d107 100644 --- a/docs/examples-docs/en-US/cell.md +++ b/docs/markdown/en-US/cell.md @@ -1,13 +1,3 @@ - - ## Cell ### Install @@ -22,66 +12,56 @@ Vue.component(CellGroup.name, CellGroup); #### Basic Usage -:::demo Basic Usage ```html - - + + ``` -::: #### Value only -:::demo Value only ```html - + ``` -::: #### Left Icon -:::demo Left Icon ```html - + ``` -::: #### Link -:::demo Link ```html - - + + ``` -::: #### Advanced Usage -:::demo Advanced Usage ```html - + - - + + ``` -::: ### API diff --git a/docs/examples-docs/en-US/changelog.md b/docs/markdown/en-US/changelog.md similarity index 99% rename from docs/examples-docs/en-US/changelog.md rename to docs/markdown/en-US/changelog.md index fee87902c2b..748d6995f6b 100644 --- a/docs/examples-docs/en-US/changelog.md +++ b/docs/markdown/en-US/changelog.md @@ -4,12 +4,10 @@ `2017-11-15` **Improvements** - -- Icon: add new icons [\#315](https://github.com/youzan/vant/pull/315) ([cookfront](https://github.com/cookfront)) +- Icon: add new icons [\#315](https://github.com/youzan/vant/pull/315) [@cookfront](https://github.com/cookfront) **Bug Fixes** - -- Search: fix box-sizing wrong [\#312](https://github.com/youzan/vant/pull/312) ([chenjiahan](https://github.com/chenjiahan)) +- Search: fix box-sizing wrong [\#312](https://github.com/youzan/vant/pull/312) [@chenjiahan](https://github.com/chenjiahan) ### [0.10.8](https://github.com/youzan/vant/tree/v0.10.8) `2017-11-11` diff --git a/docs/examples-docs/en-US/checkbox.md b/docs/markdown/en-US/checkbox.md similarity index 71% rename from docs/examples-docs/en-US/checkbox.md rename to docs/markdown/en-US/checkbox.md index b8937ed2671..ccf2b089c81 100644 --- a/docs/examples-docs/en-US/checkbox.md +++ b/docs/markdown/en-US/checkbox.md @@ -1,20 +1,3 @@ - - ## Checkbox ### Install @@ -29,34 +12,29 @@ Vue.component(CheckboxGroup.name, CheckboxGroup); #### Basic Usage -:::demo Basic Usage ```html -Checkbox 1 +Checkbox 1 ``` ```javascript export default { data() { return { - checkbox1: true + checked: true }; } }; ``` -::: #### Disabled -:::demo Disabled ```html -Checkbox 2 +Checkbox 2 ``` -::: -#### CheckboxGroup +#### Checkbox Group When Checkboxes are inside a CheckboxGroup, the checked checkboxes's name is an array and bound with CheckboxGroup by v-model. -:::demo CheckboxGroup ```html - Checkbox{{ item }} + Checkbox {{ item }} ``` -```javascript -export default { - data() { - return { - list: ['a', 'b', 'c'], - result: ['a', 'b'] - }; - } -}; -``` -::: - ### Checkbox API | Attribute | Description | Type | Default | Accepted Values | diff --git a/docs/examples-docs/en-US/contact.md b/docs/markdown/en-US/contact.md similarity index 74% rename from docs/examples-docs/en-US/contact.md rename to docs/markdown/en-US/contact.md index 5ac30d1df5f..3ad57d9aaaf 100644 --- a/docs/examples-docs/en-US/contact.md +++ b/docs/markdown/en-US/contact.md @@ -1,71 +1,3 @@ - - ## Contact 通过 Contact 组件可以实现联系人的展示、选择、编辑等功能。 @@ -82,7 +14,7 @@ Vue.component(ContactEdit.name, ContactEdit); #### Basic Usage -:::demo Basic Usage + ```html +/> @@ -106,8 +38,8 @@ Vue.component(ContactEdit.name, ContactEdit); @@ -186,7 +118,7 @@ export default { } }; ``` -::: + ### ContactCard API | Attribute | Description | Type | Default | Accepted Values | diff --git a/docs/examples-docs/en-US/coupon.md b/docs/markdown/en-US/coupon.md similarity index 72% rename from docs/examples-docs/en-US/coupon.md rename to docs/markdown/en-US/coupon.md index 87658c4fd81..50a0b8252f5 100644 --- a/docs/examples-docs/en-US/coupon.md +++ b/docs/markdown/en-US/coupon.md @@ -1,63 +1,3 @@ - - ## Coupon ### Install @@ -72,24 +12,23 @@ Vue.component(CouponList.name, CouponList); #### Basic Usage -:::demo Basic Usage ```html +/> + /> ``` @@ -127,7 +66,6 @@ export default { } } ``` -::: ### CouponCell API diff --git a/docs/examples-docs/en-US/datetime-picker.md b/docs/markdown/en-US/datetime-picker.md similarity index 74% rename from docs/examples-docs/en-US/datetime-picker.md rename to docs/markdown/en-US/datetime-picker.md index 0abf3590a46..7f3299f312b 100644 --- a/docs/examples-docs/en-US/datetime-picker.md +++ b/docs/markdown/en-US/datetime-picker.md @@ -1,21 +1,3 @@ - - ## DatetimePicker ### Install @@ -29,15 +11,14 @@ Vue.component(DatetimePicker.name, DatetimePicker); #### Basic Usage -:::demo Basic Usage ```html ``` @@ -54,25 +35,21 @@ export default { } }; ``` -::: #### Date Picker -:::demo Date Picker ```html ``` -::: #### Time Picker -:::demo Time Picker ```html ``` -::: - ### API diff --git a/docs/markdown/en-US/dialog.md b/docs/markdown/en-US/dialog.md new file mode 100644 index 00000000000..82063a860f0 --- /dev/null +++ b/docs/markdown/en-US/dialog.md @@ -0,0 +1,63 @@ +## Dialog + +### Install + +```js +import { Dialog } from 'vant'; +``` + +### Usage + +#### Alert dialog +Used to prompt for some messages, only including one confirm button + +```javascript +Dialog.alert({ + title: 'Title', + message: 'Content' +}).then(() => { + // on close +}); + +Dialog.alert({ + message: 'Content' +}).then(() => { + // on close +}); +``` + +#### Confirm dialog +Used to confirm some messages, including a confirm button and a cancel button + +```javascript + Dialog.confirm({ + title: 'Title', + message: 'Content' +}).then(() => { + // on confirm +}).catch(() => { + // on cancel +}); +``` + +### Methods + +| Name | Attribute | Return value | Description | +|-----------|-----------|-----------|-------------| +| Dialog.alert | options | `Promise` | Show alert dialog | +| Dialog.confirm | options | `Promise` | Show confim dialog | +| Dialog.close | - | `void` | Close dialog | + +### Options + +| Attribute | Description | Type | Default | Accepted Values | +|-----------|-----------|-----------|-------------|-------------| +| title | Title | `String` | - | - | +| message | Message | `String` | - | - | +| showConfirmButton | Whether to show confirm button | `Boolean` | `true` | - | +| showCancelButton | Whether to show cancel button | `Boolean` | `false` | - | +| confirmButtonText | Confirm button text | `String` | `Confirm` | - | +| cancelButtonText | Cancel button test | `String` | `Cancel` | - | +| overlay | Whether to show overlay | `Boolean` | `true` | - | +| closeOnClickOverlay | Whether to close when click overlay | `Boolean` | `false` | - | +| lockOnScroll | Whether to lock body scroll | `Boolean` | `true` | - | diff --git a/docs/examples-docs/en-US/field.md b/docs/markdown/en-US/field.md similarity index 87% rename from docs/examples-docs/en-US/field.md rename to docs/markdown/en-US/field.md index 12be8de48ee..4ae0c35307b 100644 --- a/docs/examples-docs/en-US/field.md +++ b/docs/markdown/en-US/field.md @@ -1,16 +1,3 @@ - - ## Field ### Install @@ -25,18 +12,15 @@ Vue.component(Field.name, Field); #### Basic Usage The value of filed is bound with v-model. -:::demo Basic Usage ```html ``` -::: -#### Custom Type +#### Custom type Use `type` prop to custom diffrent type fileds. -:::demo Custom Type ```html ``` -::: #### Disabled -:::demo Disabled ```html ``` -::: -#### Error Info +#### Error info -:::demo Error Info ```html ``` -::: #### Auto resize Textarea Filed can be auto resize when has `autosize` prop -:::demo Auto resize ```html ``` -::: ### API diff --git a/docs/examples-docs/en-US/goods-action.md b/docs/markdown/en-US/goods-action.md similarity index 87% rename from docs/examples-docs/en-US/goods-action.md rename to docs/markdown/en-US/goods-action.md index bd62aa34472..b5cd451f894 100644 --- a/docs/examples-docs/en-US/goods-action.md +++ b/docs/markdown/en-US/goods-action.md @@ -1,18 +1,3 @@ - - ## GoodsAction ### Install @@ -30,7 +15,7 @@ Vue.component(GoodsActionMiniBtn.name, GoodsActionMiniBtn); ### Usage -:::demo + ```html @@ -60,7 +45,6 @@ export default { } } ``` -::: ### API diff --git a/docs/markdown/en-US/icon.md b/docs/markdown/en-US/icon.md new file mode 100644 index 00000000000..ab24205fe67 --- /dev/null +++ b/docs/markdown/en-US/icon.md @@ -0,0 +1,23 @@ +## Icon + +### Install +``` javascript +import { Icon } from 'vant'; + +Vue.component(Icon.name, Icon); +``` + +### Usage + +#### Basic Usage +View all usable icons on the right. + +```html + +``` + +### API + +| Attribute | Description | Type | Default | Accepted Values | +|-----------|-----------|-----------|-------------|-------------| +| name | Icon name | `String` | `''` | - | diff --git a/docs/markdown/en-US/image-preview.md b/docs/markdown/en-US/image-preview.md new file mode 100644 index 00000000000..5fa8bd5552d --- /dev/null +++ b/docs/markdown/en-US/image-preview.md @@ -0,0 +1,32 @@ +## ImagePreview + +### Install + +```js +import { ImagePreview } from 'vant'; +``` + +### Usage + +#### Basic Usage + +```javascript +ImagePreview([ + 'https://img.yzcdn.cn/1.jpg', + 'https://img.yzcdn.cn/2.jpg' +]); +``` + +#### Custom Start Position +```javascript +ImagePreview([ + 'https://img.yzcdn.cn/1.jpg', + 'https://img.yzcdn.cn/2.jpg' +], 1); +``` + +### Arguments + +| Attribute | Description | Type | +|-----------|-----------|-----------| +| imageUrls | Image URL list | `Array` | diff --git a/docs/examples-docs/en-US/layout.md b/docs/markdown/en-US/layout.md similarity index 97% rename from docs/examples-docs/en-US/layout.md rename to docs/markdown/en-US/layout.md index 5095cb84701..0a65a42f412 100644 --- a/docs/examples-docs/en-US/layout.md +++ b/docs/markdown/en-US/layout.md @@ -16,7 +16,7 @@ Vue.component(Col.name, Col); Layout are based on 24-column. The attribute `span` in `Col` means the number of column the grid spans. Of course, You can use `offset` attribute to set number of spacing on the left side of the grid. -:::demo Basic Usage + ```html span: 8 @@ -34,13 +34,13 @@ Layout are based on 24-column. The attribute `span` in `Col` means the number of offset: 12, span: 12 ``` -::: + #### Column Spacing Set grid spacing using `gutter` attribute. The default value is 0 -:::demo Column Spacing + ```html span: 8 @@ -48,7 +48,7 @@ Set grid spacing using `gutter` attribute. The default value is 0 span: 8 ``` -::: + ### API diff --git a/docs/examples-docs/en-US/lazyload.md b/docs/markdown/en-US/lazyload.md similarity index 79% rename from docs/examples-docs/en-US/lazyload.md rename to docs/markdown/en-US/lazyload.md index 0d876e0f168..3a22a27e999 100644 --- a/docs/examples-docs/en-US/lazyload.md +++ b/docs/markdown/en-US/lazyload.md @@ -42,7 +42,6 @@ Vue.use(Lazyload, options); #### Basic Usage -:::demo Basic Usage ```html ``` @@ -59,53 +58,22 @@ export default { } } ``` -::: -#### Background Image +#### Lazyload Background Image Use `v-lazy:background-image` to set background url, and declare the height of the container. -:::demo Background Image ```html -
+
``` -```javascript -export default { - data() { - return { - backgroundImageList: [ - 'https://img.yzcdn.cn/1.jpg', - 'https://img.yzcdn.cn/2.jpg' - ] - }; - } -} -``` -::: - #### Lazyload Component -:::demo Lazyload Component ```html - + ``` -```javascript -export default { - data() { - return { - componentImageList: [ - 'https://img.yzcdn.cn/1.jpg', - 'https://img.yzcdn.cn/2.jpg' - ] - }; - } -} -``` -::: - ### Options | Attribute | Description | Type | Default | Accepted Values | diff --git a/docs/examples-docs/en-US/loading.md b/docs/markdown/en-US/loading.md similarity index 52% rename from docs/examples-docs/en-US/loading.md rename to docs/markdown/en-US/loading.md index 0f4348d9cc7..d9c03cac8bd 100644 --- a/docs/examples-docs/en-US/loading.md +++ b/docs/markdown/en-US/loading.md @@ -11,30 +11,24 @@ Vue.component(Loading.name, Loading); #### Solid Circle -:::demo Solid Circle ```html - - + + ``` -::: #### Gradient Circle -:::demo Gradient Circle ```html - - + + ``` -::: #### Spinner -:::demo Spinner ```html - - + + ``` -::: ### API diff --git a/docs/examples-docs/en-US/nav-bar.md b/docs/markdown/en-US/nav-bar.md similarity index 67% rename from docs/examples-docs/en-US/nav-bar.md rename to docs/markdown/en-US/nav-bar.md index 753fddb5588..27425dd402f 100644 --- a/docs/examples-docs/en-US/nav-bar.md +++ b/docs/markdown/en-US/nav-bar.md @@ -11,35 +11,31 @@ Vue.component(NavBar.name, NavBar); #### Basic Usage -:::demo Basic Usage ```html ``` -::: #### Advanced Usage -:::demo Advanced Usage ```html - + ``` -::: ### API | Attribute | Description | Type | Default | Accepted Values | |-----------|-----------|-----------|-------------|-------------| | title | Title | `String` | `''` | - | -| left-text | Left Text | `String` | `''` | - | -| right-text | Right Text | `String` | `''` | - | -| left-arrow | Whether to show left arrow | `Boolean` | `false` | - | +| leftText | Left Text | `String` | `''` | - | +| rightText | Right Text | `String` | `''` | - | +| leftArrow | Whether to show left arrow | `Boolean` | `false` | - | | fixed | Whether to fixed top | `Boolean` | `false` | - | ### Slot diff --git a/docs/examples-docs/en-US/notice-bar.md b/docs/markdown/en-US/notice-bar.md similarity index 90% rename from docs/examples-docs/en-US/notice-bar.md rename to docs/markdown/en-US/notice-bar.md index a8511ede101..d088579fb8a 100644 --- a/docs/examples-docs/en-US/notice-bar.md +++ b/docs/markdown/en-US/notice-bar.md @@ -11,28 +11,23 @@ Vue.component(NoticeBar.name, NoticeBar); #### Basic Usage -:::demo Basic Usage ```html ``` -::: #### Disable scroll -:::demo Disable scroll ```html Only those who have the patience to do simple things perfectly ever acquire the skill to do difficult things easily. ``` -::: #### Mode -:::demo Mode ```html Only those who have the patience to do simple things perfectly ever acquire the skill to do difficult things easily. @@ -42,7 +37,6 @@ Vue.component(NoticeBar.name, NoticeBar); Only those who have the patience to do simple things perfectly ever acquire the skill to do difficult things easily. ``` -::: ### API diff --git a/docs/examples-docs/en-US/number-keyboard.md b/docs/markdown/en-US/number-keyboard.md similarity index 82% rename from docs/examples-docs/en-US/number-keyboard.md rename to docs/markdown/en-US/number-keyboard.md index b718f2807fd..f4c065fc063 100644 --- a/docs/examples-docs/en-US/number-keyboard.md +++ b/docs/markdown/en-US/number-keyboard.md @@ -1,24 +1,3 @@ - - ## NumberKeyboard ### Install @@ -32,14 +11,13 @@ Vue.component(NumberKeyboard.name, NumberKeyboard); #### Basic Usage -:::demo Basic Usage ```html - ShowKeyboard + Show Keyboard - HideKeyboard + Hide Keyboard -
Panel Content
+
Content
``` -::: #### Advanced Usage -:::demo Advanced Usage ```html -
Panel Content
+
Content
Button Button
``` -::: ### API diff --git a/docs/examples-docs/en-US/password-input.md b/docs/markdown/en-US/password-input.md similarity index 95% rename from docs/examples-docs/en-US/password-input.md rename to docs/markdown/en-US/password-input.md index 3671faf6493..ff46c37f8a3 100644 --- a/docs/examples-docs/en-US/password-input.md +++ b/docs/markdown/en-US/password-input.md @@ -33,14 +33,13 @@ Vue.component(NumberKeyBoard.name, NumberKeyBoard); #### Basic Usage -:::demo Basic Usage ```html +/> +/> ``` ```javascript @@ -57,7 +56,7 @@ export default { return { value: '', showKeyboard: true - } + }; }, methods: { @@ -70,7 +69,6 @@ export default { } } ``` -::: ### API diff --git a/docs/examples-docs/en-US/picker.md b/docs/markdown/en-US/picker.md similarity index 68% rename from docs/examples-docs/en-US/picker.md rename to docs/markdown/en-US/picker.md index b9cfdca2f89..cd823e513e6 100644 --- a/docs/examples-docs/en-US/picker.md +++ b/docs/markdown/en-US/picker.md @@ -1,42 +1,3 @@ - - ## Picker ### Install @@ -50,9 +11,9 @@ Vue.component(Picker.name, Picker); #### Basic Usage -:::demo Basic Usage + ```html - + ``` ```javascript @@ -78,26 +39,25 @@ export default { }, methods: { - handlePickerChange(picker, values) { + onChange(picker, values) { picker.setColumnValues(1, citys[values[0]]); } } }; ``` -::: + #### Picker with toolbar -:::demo Picker with toolbar ```html + @change="onChange" + @cancel="onCancel" + @confirm="onConfirm" +/> ``` ```javascript @@ -124,19 +84,18 @@ export default { }, methods: { - handlePickerChange(picker, values) { + onChange(picker, values) { picker.setColumnValues(1, citys[values[0]]); }, - handlePickerCancel() { + onCancel() { Toast('Cancel'); }, - handlePickerConfirm() { + onConfirm() { Toast('Confirm'); } } }; ``` -::: ### API diff --git a/docs/markdown/en-US/popup.md b/docs/markdown/en-US/popup.md new file mode 100644 index 00000000000..5e14339c6cd --- /dev/null +++ b/docs/markdown/en-US/popup.md @@ -0,0 +1,48 @@ +## Popup + +### Install +``` javascript +import { Popup } from 'vant'; + +Vue.component(Popup.name, Popup); +``` + +### Usage + +#### Basic Usage +Popup is located in the middle of the screen by default + +```html +Content +``` + +```javascript +export default { + data() { + return { + show: false + } + } +}; +``` + +#### Position +Use `position` prop to set popup display position + +```html + + Content + +``` + +### API + +| Attribute | Description | Type | Default | Accepted Values | +|-----------|-----------|-----------|-------------|-------------| +| v-model | Whether to show popup | `Boolean` | `false` | - | +| overlay | Whether to show overlay | `Boolean` | `true` | - | +| lockOnScroll | Lock body scroll | `Boolean` | `false` | - | +| position | Position | `String` | - | `top` `bottom` `right` `left` | +| closeOnClickOverlay | Close popup when click overlay | `Boolean` | `true` | - | +| transition | Transition | `String` | `popup-slide` | - | +| preventScroll | Prevent background scroll | `Boolean` | `false` | - | diff --git a/docs/examples-docs/en-US/progress.md b/docs/markdown/en-US/progress.md similarity index 51% rename from docs/examples-docs/en-US/progress.md rename to docs/markdown/en-US/progress.md index f0a6a4fe2df..830dc792e36 100644 --- a/docs/examples-docs/en-US/progress.md +++ b/docs/markdown/en-US/progress.md @@ -12,36 +12,30 @@ Vue.component(Progress.name, Progress); #### Basic Usage Use 'percentage' prop to set current progress -:::demo Basic Usage ```html - - - + + + ``` -::: #### Inactive -:::demo Inactive ```html - - - + + + ``` -::: #### Custom Style -Use `pivot-text` to custom text,use `color` to custom bar color +Use `pivotText` to custom text,use `color` to custom bar color -:::demo Custom Style ```html - - - + + + ``` -::: ### API diff --git a/docs/examples-docs/en-US/pull-refresh.md b/docs/markdown/en-US/pull-refresh.md similarity index 73% rename from docs/examples-docs/en-US/pull-refresh.md rename to docs/markdown/en-US/pull-refresh.md index e68df4985c6..45d1ab0d3fc 100644 --- a/docs/examples-docs/en-US/pull-refresh.md +++ b/docs/markdown/en-US/pull-refresh.md @@ -1,33 +1,3 @@ - - ## PullRefresh ### Install @@ -39,7 +9,6 @@ Vue.component(PullRefresh.name, PullRefresh); ### Usage -:::demo ```html -export default { - data() { - return { - radio1: '1', - radio2: '2', - radio3: '1', - radio4: '1' - }; - } -}; - - ## Radio ### Install @@ -25,74 +12,43 @@ Vue.component(Radio.name, Radio); #### Basic Usage Use `v-model` to bind check status of radio. The value will be set to the name of radio when radio get checked. -:::demo Basic Usage ```html -
- Radio 1 - Radio 2 -
+Radio 1 +Radio 2 ``` + ```javascript export default { data() { return { - radio1: '1' + radio: '1' } } }; ``` -::: #### Disabled -:::demo Disabled ```html -
- Disabled - Disabled and checked -
+Disabled +Disabled and checked ``` -```javascript -export default { - data() { - return { - radio2: '2' - } - } -}; -``` -::: -#### RadioGroup +#### Radio Group When Radios are inside a RadioGroup, the checked radio's name is bound with CheckboxGroup by `v-model`. -:::demo RadioGroup ```html -
- - Radio 1 - Radio 2 - -
-``` - -```javascript -export default { - data() { - return { - radio3: '1' - } - } -}; + + Radio 1 + Radio 2 + ``` -::: -#### With Cell +#### Inside a Cell -:::demo With Cell ```html - + Radio 1 Radio 2 @@ -100,17 +56,6 @@ export default { ``` -```javascript -export default { - data() { - return { - radio4: '1' - } - } -}; -``` -::: - ### Radio API | Attribute | Description | Type | Default | Accepted Values | diff --git a/docs/examples-docs/en-US/search.md b/docs/markdown/en-US/search.md similarity index 81% rename from docs/examples-docs/en-US/search.md rename to docs/markdown/en-US/search.md index 2509ee80a98..8462c75125c 100644 --- a/docs/examples-docs/en-US/search.md +++ b/docs/markdown/en-US/search.md @@ -1,24 +1,3 @@ - - ## Search ### Install @@ -32,7 +11,6 @@ Vue.component(Search.name, Search); #### Basic Usage -:::demo Basic Usage ```html ``` @@ -44,7 +22,6 @@ export default { } } ``` -::: #### Listen to Events `search` event will be triggered when click the search button on the keyboard. @@ -53,33 +30,29 @@ export default { Tips: There will be a search button on the keyboard when Search is inside a form in iOS. -:::demo Listen to Events ```html
``` -::: #### Custom Button Use `action` slot to custom right button, `cancel` event will no longer be triggered when use this slot -:::demo Custom Button ```html
Search
``` -::: ### API diff --git a/docs/examples-docs/en-US/sku.md b/docs/markdown/en-US/sku.md similarity index 66% rename from docs/examples-docs/en-US/sku.md rename to docs/markdown/en-US/sku.md index db38c031f30..77ac19c1e68 100644 --- a/docs/examples-docs/en-US/sku.md +++ b/docs/markdown/en-US/sku.md @@ -1,44 +1,5 @@ ## Sku - - ### Install ```javascript import { Sku } from 'vant'; @@ -48,70 +9,57 @@ Vue.component(Sku.name, Sku); ### Usage #### Basic Usage -:::demo + ```html - + ``` -::: -#### 自定义sku slot区块 -:::demo +#### 自定义 sku slot 区块 + ```html - + + + + + + ``` -::: ### API diff --git a/docs/examples-docs/en-US/stepper.md b/docs/markdown/en-US/stepper.md similarity index 78% rename from docs/examples-docs/en-US/stepper.md rename to docs/markdown/en-US/stepper.md index b8dea95f9f1..fa6614d64b2 100644 --- a/docs/examples-docs/en-US/stepper.md +++ b/docs/markdown/en-US/stepper.md @@ -1,14 +1,3 @@ - - ## Stepper ### Install @@ -22,9 +11,8 @@ Vue.component(Stepper.name, Stepper); #### Basic Usage -:::demo Basic Usage ```html - + ``` ```javascript @@ -36,29 +24,24 @@ export default { } } ``` -::: #### Disabled -:::demo Disabled ```html - + ``` -::: #### Advanced Usage -:::demo Advanced Usage ```html ``` -::: ### API diff --git a/docs/examples-docs/en-US/steps.md b/docs/markdown/en-US/steps.md similarity index 66% rename from docs/examples-docs/en-US/steps.md rename to docs/markdown/en-US/steps.md index d2750537c37..d5920ecf5ce 100644 --- a/docs/examples-docs/en-US/steps.md +++ b/docs/markdown/en-US/steps.md @@ -1,19 +1,3 @@ - - ## Steps ### Install @@ -28,7 +12,6 @@ Vue.component(Steps.name, Steps); #### Basic Usage -:::demo Basic Usage ```html Step1 @@ -36,8 +19,6 @@ Vue.component(Steps.name, Steps); Step3 Step4 - -Next ``` ```javascript @@ -46,25 +27,16 @@ export default { return { active: 0 }; - }, - - methods: { - nextStep() { - this.active = ++this.active % 4; - } } } ``` -::: #### Description -:::demo Description ```html @@ -74,13 +46,11 @@ export default { Step4 ``` -::: #### Vertical Steps -:::demo Vertical Steps ```html - +

【City】Status1

2016-07-12 12:40

@@ -95,22 +65,6 @@ export default {
``` -::: - -#### Advanced Usage - -:::demo Advanced Usage -```html - - -

Some text

- Step1 - Step2 - Step3 - Step4 -
-``` -::: ### Steps API diff --git a/docs/examples-docs/en-US/submit-bar.md b/docs/markdown/en-US/submit-bar.md similarity index 78% rename from docs/examples-docs/en-US/submit-bar.md rename to docs/markdown/en-US/submit-bar.md index e30a974473b..0cb50211281 100644 --- a/docs/examples-docs/en-US/submit-bar.md +++ b/docs/markdown/en-US/submit-bar.md @@ -37,67 +37,61 @@ Vue.component(SubmitBar.name, SubmitBar); #### Basic Usage -:::demo Basic Usage ```html ``` -::: #### Disabled 禁用状态下不会触发`submit`事件 -:::demo 禁用状态 ```html ``` -::: #### Loading 加载状态下不会触发`submit`事件 -:::demo 加载状态 + ```html ``` -::: -#### +#### Advanced Usage 提示文案中的额外操作和说明 -:::demo 提示文案中添加操作 + ```html - 您的收货地址不支持同城送, 修改地址 > + 您的收货地址不支持同城送, 修改地址 > ``` -::: ### API | Attribute | Description | Type | Default | 必须 | |-----------|-----------|-----------|-------------|-------------| | price | 价格(单位分) | `Number` | - | 是 | -| button-text | 按钮文字 | `String` | - | 是 | -| button-type | 按钮类型 | `String` | `danger` | 否 | +| buttonText | 按钮文字 | `String` | - | 是 | +| buttonType | 按钮类型 | `String` | `danger` | 否 | | tip | 提示文案 | `String` | - | 否 | | disabled | 是否禁用按钮 | `Boolean` | `false` | 否 | | loading | 是否显示加载中的按钮 | `Boolean` | `false` | 否 | diff --git a/docs/examples-docs/en-US/swipe.md b/docs/markdown/en-US/swipe.md similarity index 73% rename from docs/examples-docs/en-US/swipe.md rename to docs/markdown/en-US/swipe.md index 5c228790979..8d89337e51c 100644 --- a/docs/examples-docs/en-US/swipe.md +++ b/docs/markdown/en-US/swipe.md @@ -1,18 +1,3 @@ - - ## Swipe ### Install @@ -28,7 +13,6 @@ Vue.component(SwipeItem.name, SwipeItem); #### Basic Usage Use `autoplay` prop to set autoplay interval -:::demo Basic Usage ```html 1 @@ -37,12 +21,10 @@ Use `autoplay` prop to set autoplay interval 4 ``` -::: #### Image Lazyload Use [Lazyload](#/zh-CN/component/lazyload) component to lazyload image -:::demo Image Lazyload ```html @@ -63,7 +45,6 @@ export default { } } ``` -::: ### API diff --git a/docs/examples-docs/en-US/switch-cell.md b/docs/markdown/en-US/switch-cell.md similarity index 75% rename from docs/examples-docs/en-US/switch-cell.md rename to docs/markdown/en-US/switch-cell.md index cc7f203622c..87d1ffb06ce 100644 --- a/docs/examples-docs/en-US/switch-cell.md +++ b/docs/markdown/en-US/switch-cell.md @@ -1,17 +1,6 @@ ## SwitchCell - `SwitchCell` component is an encapsulation of `Switch` and `Cell`. - - ### Install ``` javascript import { SwitchCell } from 'vant'; @@ -23,10 +12,9 @@ Vue.component(SwitchCell.name, SwitchCell); #### Basic Usage -:::demo Basic Usage ```html - + ``` @@ -39,29 +27,26 @@ export default { } } ``` -::: + #### Disabled use `disabled` property to disable the component -:::demo Disabled component ```html - + ``` -::: + #### Loading use `loading` property to keep component in loading state -:::demo Component in loading ```html - + ``` -::: ### API diff --git a/docs/examples-docs/en-US/switch.md b/docs/markdown/en-US/switch.md similarity index 65% rename from docs/examples-docs/en-US/switch.md rename to docs/markdown/en-US/switch.md index 6868d48fde9..6a71930cf1b 100644 --- a/docs/examples-docs/en-US/switch.md +++ b/docs/markdown/en-US/switch.md @@ -1,29 +1,3 @@ - - ## Switch ### Install @@ -37,7 +11,6 @@ Vue.component(Switch.name, Switch); #### Basic Usage -:::demo Basic Usage ```html ``` @@ -51,35 +24,31 @@ export default { } }; ``` -::: #### Disabled -:::demo Disabled ```html ``` -::: #### Loading -:::demo Loading ```html ``` -::: #### Advanced usage -:::demo Advanced usage + ```html - + ``` + ```js export default { data() { return { - checked2: true + checked: true }; }, @@ -89,13 +58,12 @@ export default { title: 'Confirm', message: 'Are you sure to toggle switch?' }).then(() => { - this.checked2 = checked; + this.checked = checked; }); } } }; ``` -::: ### API diff --git a/docs/markdown/en-US/tab.md b/docs/markdown/en-US/tab.md new file mode 100644 index 00000000000..f500a941a18 --- /dev/null +++ b/docs/markdown/en-US/tab.md @@ -0,0 +1,125 @@ +## Tabs + +### Install +``` javascript +import { Tab, Tabs } from 'vant'; + +Vue.component(Tab.name, Tab); +Vue.component(Tabs.name, Tabs); +``` + +### Usage + +#### Basic Usage + +By default, the first tab is actived. You can set `active` attribute on `van-tabs` to active specified tab. + +```html + + + content of tab {{ index }} + + +``` + +```js +export default { + data() { + return { + active: 2 + }; + } +} +``` + +#### Swipe Tabs + +By default more than 4 tabs, you can scroll through the tabs. You can set `swipeThreshold` attribute to customize threshold number. + +```html + + + content of tab {{ index }} + + +``` + +#### Disabled Tab + +You can set `disabled` attribute on the corresponding `van-tab`. + +```html + + + content of tab {{ index }} + + +``` + +```javascript +export default { + methods: { + onClickDisabled() { + Toast('Disabled!'); + } + } +}; +``` + +#### Card Style + +Tabs styled as cards. + +```html + + + content of tab {{ index }} + + +``` + +#### Click Event + +You can bind `click` event on `van-tabs`, the event handler function has one parameters: index of click tab. + +```html + + + content of tab {{ index }} + + +``` + +```javascript +export default { + methods: { + handleTabClick(index) { + Toast(index); + } + } +}; +``` + +### Tabs API + +| Attribute | Description | Type | Default | Accepted Values | +|-----------|-----------|-----------|-------------|-------------| +| type | There are two style tabs, set this attribute to change tab style | `String` | `line` | `card` | +| active | Index of active tab | `String` `Number` | `0` | - | +| duration | Toggle tab's animation time | `Number` | `0.3` | - | - | +| swipeThreshold | Set swipe tabs threshold | `Number` | `4` | - | - | + +### Tab API + +| Attribute | Description | Type | Default | Accepted Values | +|-----------|-----------|-----------|-------------|-------------| +| title | Tab title | `String` | - | - | +| disabled | Whether disabled current tab | `Boolean` | `false` | - | + +### Tabs Event + +| Event | Description | Attribute | +|-----------|-----------|-----------| +| click | Triggered when click tab | index:index of current tab | +| disabled | Triggered when click disabled tab | index:index of current tab | + diff --git a/docs/examples-docs/en-US/tabbar.md b/docs/markdown/en-US/tabbar.md similarity index 79% rename from docs/examples-docs/en-US/tabbar.md rename to docs/markdown/en-US/tabbar.md index 4894d7270d1..16cea64183e 100644 --- a/docs/examples-docs/en-US/tabbar.md +++ b/docs/markdown/en-US/tabbar.md @@ -1,20 +1,5 @@ ## Tabbar - - ### Install ``` javascript import { Tabbar, TabbarItem } from 'vant'; @@ -27,7 +12,6 @@ Vue.component(TabbarItem.name, TabbarItem); #### Basic Usage -:::demo Basic Usage ```html Tab @@ -46,17 +30,15 @@ export default { } } ``` -::: #### Custom icon Use `icon` slot to custom icon -:::demo Custom icon ```html - + Custom - + Tab Tab @@ -67,7 +49,7 @@ Use `icon` slot to custom icon export default { data() { return { - active2: 0, + active: 0, icon: { normal: '//img.yzcdn.cn/1.png', active: '//img.yzcdn.cn/2.png' @@ -76,7 +58,6 @@ export default { } } ``` -::: ### Tabbar API diff --git a/docs/examples-docs/en-US/tag.md b/docs/markdown/en-US/tag.md similarity index 93% rename from docs/examples-docs/en-US/tag.md rename to docs/markdown/en-US/tag.md index 49ac4b432e2..60d836db066 100644 --- a/docs/examples-docs/en-US/tag.md +++ b/docs/markdown/en-US/tag.md @@ -11,36 +11,30 @@ Vue.component(Tag.name, Tag); #### Basic Usage -:::demo Basic Usage ```html Tag Tag Tag Tag ``` -::: #### Plain style -:::demo Plain style ```html Tag Tag Tag Tag ``` -::: #### Mark style -:::demo Mark style ```html Tag Tag Tag Tag ``` -::: ### API diff --git a/docs/markdown/en-US/theme.md b/docs/markdown/en-US/theme.md new file mode 100644 index 00000000000..5ec97e58671 --- /dev/null +++ b/docs/markdown/en-US/theme.md @@ -0,0 +1,55 @@ +## Custom Theme (In translation) + +`Vant`提供了一套默认主题,CSS 命名采用 BEM 的风格,方便使用者覆盖样式。如果你想完全替换主题色或者其他样式,可以使用下面的方法: + +### 方案一. PostCSS 插件 +在项目中直接引入组件对应的 postcss 源代码,并通过 postcss 插件 [postcss-theme-variables](https://www.npmjs.com/package/postcss-theme-variables) 替换颜色变量,步骤如下: + +```javascript +// 引入基础样式 +import 'vant/packages/vant-css/src/base.css'; + +// 引入组价对应的样式 +import 'vant/packages/vant-css/src/button.css'; +import 'vant/packages/vant-css/src/checkbox.css'; +``` + +接着在 postcss.config.js 中引入所需的 postcss 插件,并根据项目需求配置颜色变量,所有可用的颜色变量请参考 [配置文件](https://github.com/youzan/vant/blob/dev/packages/vant-css/src/common/var.css) + +```javascript +module.exports = { + plugins: [ + require('postcss-easy-import')({ + extensions: ['pcss', 'css'] + }), + require('postcss-theme-variables')({ + vars: { + red: '#F60', + gray: '#CCC', + blue: '#03A9F4' + }, + prefix: '$' + }), + require('precss')(), + require('postcss-calc')(), + require('autoprefixer')({ + browsers: ['Android >= 4.0', 'iOS >= 7'] + }) + ] +}; +``` + +### 方案二. 本地构建 +可以通过在本地构建 vant-css 的方式生成所需的主题 + +```bash +# 克隆仓库 +git clone git@github.com:youzan/vant.git +cd packages/vant-css +``` + +在本地 vant-css 仓库中,修改 src/common/var.css 中的颜色变量,然后执行以下构建命令,即可生成对应的样式文件 +```bash +npm run build +``` + diff --git a/docs/markdown/en-US/toast.md b/docs/markdown/en-US/toast.md new file mode 100644 index 00000000000..73739ced245 --- /dev/null +++ b/docs/markdown/en-US/toast.md @@ -0,0 +1,73 @@ +## Toast + +### Install + +```javascript +import { Toast } from 'vant'; +``` + +### Usage + +#### Text + +```javascript +Toast('Some messages'); +``` + + +#### Loading + +```javascript +Toast.loading({ mask: true }); +``` + + +#### Success/Fail + +```javascript +Toast.success('Success'); +Toast.fail('Fail'); +``` + + +#### Advanced Usage + +```javascript +const toast = Toast.loading({ + duration: 0, // continuous display toast + forbidClick: true, // forbid click background + message: '3 seconds' +}); + +let second = 3; +const timer = setInterval(() => { + second--; + if (second) { + toast.message = `${second} seconds`; + } else { + clearInterval(timer); + Toast.clear(); + } +}, 1000); +``` + +### Methods + +| Methods | Attribute | Return value | Description | +|-----------|-----------|-----------|-------------| +| Toast | `options | message` | toast instance | Show toast | +| Toast.loading | `options | message` | toast instance | Show loading toast | +| Toast.success | `options | message` | toast instance | Show success toast | +| Toast.fail | `options | message` | toast instance | Show fail toast | +| Toast.clear | - | `void` | Close | + +### Options + +| Attribute | Description | Type | Default | Accepted Values | +|-----------|-----------|-----------|-------------|-------------| +| type | Type | `String` | `text` | `loading` `success` `fail` `html` | +| message | Message | `String` | `''` | - | +| position | Position | `String` | `middle` | `top` `bottom` | +| mask | Whether to show mask | `Boolean` | `false` | - | +| forbidClick | Whether to forbid click background | `Boolean` | `false` | - | +| duration | Toast duration(ms) | `Number` | `3000` | Toast won't disappear if value is 0 | diff --git a/docs/examples-docs/en-US/tree-select.md b/docs/markdown/en-US/tree-select.md similarity index 53% rename from docs/examples-docs/en-US/tree-select.md rename to docs/markdown/en-US/tree-select.md index 7bf53824c47..602ca1146f0 100644 --- a/docs/examples-docs/en-US/tree-select.md +++ b/docs/markdown/en-US/tree-select.md @@ -1,79 +1,3 @@ - - ## TreeSelect ### Install @@ -87,7 +11,6 @@ Vue.component(TreeSelect.name, TreeSelect); #### Basic Usage -:::demo Basic Usage ```html +/> ``` ```javascript @@ -114,13 +37,11 @@ export default { this.mainActiveIndex = index; }, onItemClick(data) { - console.log(data); this.activeId = data.id; } } } ``` -::: ### API @@ -128,9 +49,9 @@ export default { | Attribute | Description | Type | Default | 必须 | |-----------|-----------|-----------|-------------|-------------| -| items | Required datasets for the component, see Data Structure for detail. | Array | [] | - | -| mainActiveIndex | The index of selected parent node | Number | 0 | - | -| activeId | Id of selected item | Number | 0 | - | +| items | Required datasets for the component, see Data Structure for detail. | `Array` | `[]` | - | +| mainActiveIndex | The index of selected parent node | `Number` | `0` | - | +| activeId | Id of selected item | `Number` | `0` | - | #### Event | Event | Description | Attribute | diff --git a/docs/markdown/en-US/uploader.md b/docs/markdown/en-US/uploader.md new file mode 100644 index 00000000000..b3becdc988c --- /dev/null +++ b/docs/markdown/en-US/uploader.md @@ -0,0 +1,45 @@ +## Uploader + +### Install +``` javascript +import { Uploader } from 'vant'; + +Vue.component(Uploader.name, Uploader); +``` + +### Usage + +#### Basic Usage + +```html +
+ + + +
+``` + +```javascript +export default { + methods: { + logContent(file) { + console.log(file) + } + } +}; +``` + +### API + +| Attribute | Description | Type | Default | Accepted Values | +|-----------|-----------|-----------|-------------|-------------| +| resultType | The way to read the file, read as base64; read as text | `String` | `dataUrl` | `text` | +| disable | Whether to disable the upload, set to true during the image upload to prevent users from clicking this component to upload pictures | `Boolean` | `false` | - | +| beforeRead | Hook before reading the file, the first parameter is the selected file, return false to stop reading the file | `Function` | - | - | +| afterRead | Hook after reading the file, parameter format: { file ,content } | `Function` | - | - | + +### Slot + +| name | Description | +|-----------|-----------| +| - | Custom icon | diff --git a/docs/examples-docs/en-US/waterfall.md b/docs/markdown/en-US/waterfall.md similarity index 72% rename from docs/examples-docs/en-US/waterfall.md rename to docs/markdown/en-US/waterfall.md index 5937a5517d5..dea65a31e9c 100644 --- a/docs/examples-docs/en-US/waterfall.md +++ b/docs/markdown/en-US/waterfall.md @@ -27,40 +27,9 @@ export default { ### Usage - - #### Basic Usage -:::demo Basic Usage ```html -

This list will load items will scroll to bottom.

    { + progress.done(); + }).catch(() => { + progress.done(); + }); + }; +} + +export default { + 'zh-CN/actionsheet': wrapper(r => require.ensure([], () => r(require('./zh-CN/actionsheet.md')), 'zh-CN/actionsheet')), + 'zh-CN/address-edit': wrapper(r => require.ensure([], () => r(require('./zh-CN/address-edit.md')), 'zh-CN/address-edit')), + 'zh-CN/address-list': wrapper(r => require.ensure([], () => r(require('./zh-CN/address-list.md')), 'zh-CN/address-list')), + 'zh-CN/area': wrapper(r => require.ensure([], () => r(require('./zh-CN/area.md')), 'zh-CN/area')), + 'zh-CN/badge': wrapper(r => require.ensure([], () => r(require('./zh-CN/badge.md')), 'zh-CN/badge')), + 'zh-CN/button': wrapper(r => require.ensure([], () => r(require('./zh-CN/button.md')), 'zh-CN/button')), + 'zh-CN/card': wrapper(r => require.ensure([], () => r(require('./zh-CN/card.md')), 'zh-CN/card')), + 'zh-CN/cell-swipe': wrapper(r => require.ensure([], () => r(require('./zh-CN/cell-swipe.md')), 'zh-CN/cell-swipe')), + 'zh-CN/cell': wrapper(r => require.ensure([], () => r(require('./zh-CN/cell.md')), 'zh-CN/cell')), + 'zh-CN/changelog-generated': wrapper(r => require.ensure([], () => r(require('./zh-CN/changelog-generated.md')), 'zh-CN/changelog-generated')), + 'zh-CN/changelog': wrapper(r => require.ensure([], () => r(require('./zh-CN/changelog.md')), 'zh-CN/changelog')), + 'zh-CN/checkbox': wrapper(r => require.ensure([], () => r(require('./zh-CN/checkbox.md')), 'zh-CN/checkbox')), + 'zh-CN/contact': wrapper(r => require.ensure([], () => r(require('./zh-CN/contact.md')), 'zh-CN/contact')), + 'zh-CN/coupon': wrapper(r => require.ensure([], () => r(require('./zh-CN/coupon.md')), 'zh-CN/coupon')), + 'zh-CN/datetime-picker': wrapper(r => require.ensure([], () => r(require('./zh-CN/datetime-picker.md')), 'zh-CN/datetime-picker')), + 'zh-CN/dialog': wrapper(r => require.ensure([], () => r(require('./zh-CN/dialog.md')), 'zh-CN/dialog')), + 'zh-CN/field': wrapper(r => require.ensure([], () => r(require('./zh-CN/field.md')), 'zh-CN/field')), + 'zh-CN/goods-action': wrapper(r => require.ensure([], () => r(require('./zh-CN/goods-action.md')), 'zh-CN/goods-action')), + 'zh-CN/icon': wrapper(r => require.ensure([], () => r(require('./zh-CN/icon.md')), 'zh-CN/icon')), + 'zh-CN/image-preview': wrapper(r => require.ensure([], () => r(require('./zh-CN/image-preview.md')), 'zh-CN/image-preview')), + 'zh-CN/layout': wrapper(r => require.ensure([], () => r(require('./zh-CN/layout.md')), 'zh-CN/layout')), + 'zh-CN/lazyload': wrapper(r => require.ensure([], () => r(require('./zh-CN/lazyload.md')), 'zh-CN/lazyload')), + 'zh-CN/loading': wrapper(r => require.ensure([], () => r(require('./zh-CN/loading.md')), 'zh-CN/loading')), + 'zh-CN/nav-bar': wrapper(r => require.ensure([], () => r(require('./zh-CN/nav-bar.md')), 'zh-CN/nav-bar')), + 'zh-CN/notice-bar': wrapper(r => require.ensure([], () => r(require('./zh-CN/notice-bar.md')), 'zh-CN/notice-bar')), + 'zh-CN/number-keyboard': wrapper(r => require.ensure([], () => r(require('./zh-CN/number-keyboard.md')), 'zh-CN/number-keyboard')), + 'zh-CN/panel': wrapper(r => require.ensure([], () => r(require('./zh-CN/panel.md')), 'zh-CN/panel')), + 'zh-CN/password-input': wrapper(r => require.ensure([], () => r(require('./zh-CN/password-input.md')), 'zh-CN/password-input')), + 'zh-CN/picker': wrapper(r => require.ensure([], () => r(require('./zh-CN/picker.md')), 'zh-CN/picker')), + 'zh-CN/popup': wrapper(r => require.ensure([], () => r(require('./zh-CN/popup.md')), 'zh-CN/popup')), + 'zh-CN/progress': wrapper(r => require.ensure([], () => r(require('./zh-CN/progress.md')), 'zh-CN/progress')), + 'zh-CN/pull-refresh': wrapper(r => require.ensure([], () => r(require('./zh-CN/pull-refresh.md')), 'zh-CN/pull-refresh')), + 'zh-CN/quickstart': wrapper(r => require.ensure([], () => r(require('./zh-CN/quickstart.md')), 'zh-CN/quickstart')), + 'zh-CN/radio': wrapper(r => require.ensure([], () => r(require('./zh-CN/radio.md')), 'zh-CN/radio')), + 'zh-CN/search': wrapper(r => require.ensure([], () => r(require('./zh-CN/search.md')), 'zh-CN/search')), + 'zh-CN/sku': wrapper(r => require.ensure([], () => r(require('./zh-CN/sku.md')), 'zh-CN/sku')), + 'zh-CN/stepper': wrapper(r => require.ensure([], () => r(require('./zh-CN/stepper.md')), 'zh-CN/stepper')), + 'zh-CN/steps': wrapper(r => require.ensure([], () => r(require('./zh-CN/steps.md')), 'zh-CN/steps')), + 'zh-CN/submit-bar': wrapper(r => require.ensure([], () => r(require('./zh-CN/submit-bar.md')), 'zh-CN/submit-bar')), + 'zh-CN/swipe': wrapper(r => require.ensure([], () => r(require('./zh-CN/swipe.md')), 'zh-CN/swipe')), + 'zh-CN/switch-cell': wrapper(r => require.ensure([], () => r(require('./zh-CN/switch-cell.md')), 'zh-CN/switch-cell')), + 'zh-CN/switch': wrapper(r => require.ensure([], () => r(require('./zh-CN/switch.md')), 'zh-CN/switch')), + 'zh-CN/tab': wrapper(r => require.ensure([], () => r(require('./zh-CN/tab.md')), 'zh-CN/tab')), + 'zh-CN/tabbar': wrapper(r => require.ensure([], () => r(require('./zh-CN/tabbar.md')), 'zh-CN/tabbar')), + 'zh-CN/tag': wrapper(r => require.ensure([], () => r(require('./zh-CN/tag.md')), 'zh-CN/tag')), + 'zh-CN/theme': wrapper(r => require.ensure([], () => r(require('./zh-CN/theme.md')), 'zh-CN/theme')), + 'zh-CN/toast': wrapper(r => require.ensure([], () => r(require('./zh-CN/toast.md')), 'zh-CN/toast')), + 'zh-CN/tree-select': wrapper(r => require.ensure([], () => r(require('./zh-CN/tree-select.md')), 'zh-CN/tree-select')), + 'zh-CN/uploader': wrapper(r => require.ensure([], () => r(require('./zh-CN/uploader.md')), 'zh-CN/uploader')), + 'zh-CN/waterfall': wrapper(r => require.ensure([], () => r(require('./zh-CN/waterfall.md')), 'zh-CN/waterfall')), + 'en-US/actionsheet': wrapper(r => require.ensure([], () => r(require('./en-US/actionsheet.md')), 'en-US/actionsheet')), + 'en-US/address-edit': wrapper(r => require.ensure([], () => r(require('./en-US/address-edit.md')), 'en-US/address-edit')), + 'en-US/address-list': wrapper(r => require.ensure([], () => r(require('./en-US/address-list.md')), 'en-US/address-list')), + 'en-US/area': wrapper(r => require.ensure([], () => r(require('./en-US/area.md')), 'en-US/area')), + 'en-US/badge': wrapper(r => require.ensure([], () => r(require('./en-US/badge.md')), 'en-US/badge')), + 'en-US/button': wrapper(r => require.ensure([], () => r(require('./en-US/button.md')), 'en-US/button')), + 'en-US/card': wrapper(r => require.ensure([], () => r(require('./en-US/card.md')), 'en-US/card')), + 'en-US/cell-swipe': wrapper(r => require.ensure([], () => r(require('./en-US/cell-swipe.md')), 'en-US/cell-swipe')), + 'en-US/cell': wrapper(r => require.ensure([], () => r(require('./en-US/cell.md')), 'en-US/cell')), + 'en-US/changelog': wrapper(r => require.ensure([], () => r(require('./en-US/changelog.md')), 'en-US/changelog')), + 'en-US/checkbox': wrapper(r => require.ensure([], () => r(require('./en-US/checkbox.md')), 'en-US/checkbox')), + 'en-US/contact': wrapper(r => require.ensure([], () => r(require('./en-US/contact.md')), 'en-US/contact')), + 'en-US/coupon': wrapper(r => require.ensure([], () => r(require('./en-US/coupon.md')), 'en-US/coupon')), + 'en-US/datetime-picker': wrapper(r => require.ensure([], () => r(require('./en-US/datetime-picker.md')), 'en-US/datetime-picker')), + 'en-US/dialog': wrapper(r => require.ensure([], () => r(require('./en-US/dialog.md')), 'en-US/dialog')), + 'en-US/field': wrapper(r => require.ensure([], () => r(require('./en-US/field.md')), 'en-US/field')), + 'en-US/goods-action': wrapper(r => require.ensure([], () => r(require('./en-US/goods-action.md')), 'en-US/goods-action')), + 'en-US/icon': wrapper(r => require.ensure([], () => r(require('./en-US/icon.md')), 'en-US/icon')), + 'en-US/image-preview': wrapper(r => require.ensure([], () => r(require('./en-US/image-preview.md')), 'en-US/image-preview')), + 'en-US/layout': wrapper(r => require.ensure([], () => r(require('./en-US/layout.md')), 'en-US/layout')), + 'en-US/lazyload': wrapper(r => require.ensure([], () => r(require('./en-US/lazyload.md')), 'en-US/lazyload')), + 'en-US/loading': wrapper(r => require.ensure([], () => r(require('./en-US/loading.md')), 'en-US/loading')), + 'en-US/nav-bar': wrapper(r => require.ensure([], () => r(require('./en-US/nav-bar.md')), 'en-US/nav-bar')), + 'en-US/notice-bar': wrapper(r => require.ensure([], () => r(require('./en-US/notice-bar.md')), 'en-US/notice-bar')), + 'en-US/number-keyboard': wrapper(r => require.ensure([], () => r(require('./en-US/number-keyboard.md')), 'en-US/number-keyboard')), + 'en-US/panel': wrapper(r => require.ensure([], () => r(require('./en-US/panel.md')), 'en-US/panel')), + 'en-US/password-input': wrapper(r => require.ensure([], () => r(require('./en-US/password-input.md')), 'en-US/password-input')), + 'en-US/picker': wrapper(r => require.ensure([], () => r(require('./en-US/picker.md')), 'en-US/picker')), + 'en-US/popup': wrapper(r => require.ensure([], () => r(require('./en-US/popup.md')), 'en-US/popup')), + 'en-US/progress': wrapper(r => require.ensure([], () => r(require('./en-US/progress.md')), 'en-US/progress')), + 'en-US/pull-refresh': wrapper(r => require.ensure([], () => r(require('./en-US/pull-refresh.md')), 'en-US/pull-refresh')), + 'en-US/quickstart': wrapper(r => require.ensure([], () => r(require('./en-US/quickstart.md')), 'en-US/quickstart')), + 'en-US/radio': wrapper(r => require.ensure([], () => r(require('./en-US/radio.md')), 'en-US/radio')), + 'en-US/search': wrapper(r => require.ensure([], () => r(require('./en-US/search.md')), 'en-US/search')), + 'en-US/sku': wrapper(r => require.ensure([], () => r(require('./en-US/sku.md')), 'en-US/sku')), + 'en-US/stepper': wrapper(r => require.ensure([], () => r(require('./en-US/stepper.md')), 'en-US/stepper')), + 'en-US/steps': wrapper(r => require.ensure([], () => r(require('./en-US/steps.md')), 'en-US/steps')), + 'en-US/submit-bar': wrapper(r => require.ensure([], () => r(require('./en-US/submit-bar.md')), 'en-US/submit-bar')), + 'en-US/swipe': wrapper(r => require.ensure([], () => r(require('./en-US/swipe.md')), 'en-US/swipe')), + 'en-US/switch-cell': wrapper(r => require.ensure([], () => r(require('./en-US/switch-cell.md')), 'en-US/switch-cell')), + 'en-US/switch': wrapper(r => require.ensure([], () => r(require('./en-US/switch.md')), 'en-US/switch')), + 'en-US/tab': wrapper(r => require.ensure([], () => r(require('./en-US/tab.md')), 'en-US/tab')), + 'en-US/tabbar': wrapper(r => require.ensure([], () => r(require('./en-US/tabbar.md')), 'en-US/tabbar')), + 'en-US/tag': wrapper(r => require.ensure([], () => r(require('./en-US/tag.md')), 'en-US/tag')), + 'en-US/theme': wrapper(r => require.ensure([], () => r(require('./en-US/theme.md')), 'en-US/theme')), + 'en-US/toast': wrapper(r => require.ensure([], () => r(require('./en-US/toast.md')), 'en-US/toast')), + 'en-US/tree-select': wrapper(r => require.ensure([], () => r(require('./en-US/tree-select.md')), 'en-US/tree-select')), + 'en-US/uploader': wrapper(r => require.ensure([], () => r(require('./en-US/uploader.md')), 'en-US/uploader')), + 'en-US/waterfall': wrapper(r => require.ensure([], () => r(require('./en-US/waterfall.md')), 'en-US/waterfall')) +}; diff --git a/docs/markdown/zh-CN/actionsheet.md b/docs/markdown/zh-CN/actionsheet.md new file mode 100644 index 00000000000..895e44b761d --- /dev/null +++ b/docs/markdown/zh-CN/actionsheet.md @@ -0,0 +1,86 @@ +## Actionsheet 行动按钮 + +### 使用指南 +``` javascript +import { Actionsheet } from 'vant'; + +Vue.component(Actionsheet.name, Actionsheet); +``` + +### 代码演示 + +#### 基础用法 +需要传入一个`actions`的数组,数组的每一项是一个对象,对象属性见文档下方表格。 + +```html + +``` + +```javascript +export default { + data() { + return { + show: false, + actions: [ + { + name: '选项', + callback: this.onClick + }, + { + name: '信用卡支付' + }, + { + name: '选项', + loading: true + } + ] + }; + }, + + methods: { + onClick(item) { + Toast(item.name); + } + } +} +``` + +#### 带取消按钮的 Actionsheet + +如果传入了`cancelText`属性,且不为空,则会在下方显示一个取消按钮,点击会将当前`Actionsheet`关闭。 + +```html + +``` + +#### 带标题的 Actionsheet + +如果传入了`title`属性,且不为空,则另外一种样式的`Actionsheet`,里面内容需要自定义。 + +```html + +

    一些内容

    +
    +``` + +### API + +| 参数 | 说明 | 类型 | 默认值 | 可选值 | +|-----------|-----------|-----------|-------------|-------------| +| actions | 行动按钮数组 | `Array` | `[]` | - | +| title | 标题 | `String` | - | - | +| cancelText | 取消按钮文案 | `String` | - | - | +| overlay | 是否显示遮罩 | `Boolean` | - | - | +| closeOnClickOverlay | 点击遮罩是否关闭`Actionsheet` | `Boolean` | - | - | + +### actions + +`API`中的`actions`为一个对象数组,数组中的每一个对象配置每一列,每一列有以下`key`: + +| key | 说明 | +|-----------|-----------| +| name | 标题 | +| subname | 二级标题 | +| className | 为对应列添加特殊的`class` | +| loading | 是否是`loading`状态 | +| callback | 点击时的回调。该回调接受一个参数,参数为当前点击`action`的对象信息 | diff --git a/docs/examples-docs/zh-CN/address-edit.md b/docs/markdown/zh-CN/address-edit.md similarity index 75% rename from docs/examples-docs/zh-CN/address-edit.md rename to docs/markdown/zh-CN/address-edit.md index 2fd6144d7b2..99a772285b3 100644 --- a/docs/examples-docs/zh-CN/address-edit.md +++ b/docs/markdown/zh-CN/address-edit.md @@ -1,41 +1,3 @@ - - ## AddressEdit 地址编辑 ### 使用指南 @@ -49,14 +11,13 @@ Vue.component(AddressEdit.name, AddressEdit); #### 基础用法 -:::demo 基础用法 ```html -import { Toast } from 'packages'; - -export default { - data() { - return { - chosenAddressId: '1', - list: [ - { - id: '1', - name: '张三', - tel: '13000000000', - address: '浙江省杭州市西湖区文三路 138 号东方通信大厦 7 楼 501 室' - }, - { - id: '2', - name: '李四', - tel: '1310000000', - address: '浙江省杭州市拱墅区莫干山路 50 号' - }, - { - id: '3', - name: '王五', - tel: '1320000000', - address: '浙江省杭州市滨江区江南大道 15 号' - } - ] - } - }, - - methods: { - onAdd() { - Toast('新增收货地址'); - }, - onEdit(item, index) { - Toast('编辑收货地址:' + index); - } - } -} - - ## AddressList 地址列表 ### 使用指南 @@ -52,7 +11,6 @@ Vue.component(AddressList.name, AddressList); #### 基础用法 -:::demo 基础用法 ```html -import AreaList from '../../mock/area.json'; - -export default { - data() { - return { - areaList: AreaList - } - } -}; - - ## Area 省市县选择组件 ### 使用指南 @@ -26,43 +14,27 @@ Vue.component(Area.name, Area); 要初始化一个`Area`组件,你需要传入一个`areaList`属性,`areaList`数据格式具体可看下面数据格式章节。 -:::demo 基础用法 ```html - - - + ``` -::: + #### 选中省市县 如果想选中某个省市县,需要传入一个`value`属性,绑定对应的省市县`code`。 -:::demo 选中省市县 ```html - + ``` -::: + #### 配置显示列 可以通过`columnsNum`属性配置省市县显示的列数,默认情况下会显示省市县,当你设置为`2`,则只会显示省市选择。 -:::demo 配置显示列 ```html - + ``` -::: ### API @@ -115,7 +87,7 @@ export default { } ``` -完整数据见 [Area.json](https://github.com/youzan/vant/blob/dev/docs/mock/area.json) +完整数据见 [Area.json](https://github.com/youzan/vant/blob/dev/docs/demos/mock/area.json) #### 点击完成时返回的数据格式 返回的数据整体为一个数组,数组内包含 `columnsNum` 个数据, 每个数据对应一列选项中被选中的数据。 diff --git a/docs/examples-docs/zh-CN/badge.md b/docs/markdown/zh-CN/badge.md similarity index 73% rename from docs/examples-docs/zh-CN/badge.md rename to docs/markdown/zh-CN/badge.md index 3fed127a1a4..028f52388cc 100644 --- a/docs/examples-docs/zh-CN/badge.md +++ b/docs/markdown/zh-CN/badge.md @@ -1,38 +1,3 @@ - - - - ## Badge 徽章 ### 使用指南 @@ -48,7 +13,6 @@ Vue.component(Badge.name, Badge); 通过在`van-badge-group`上设置`active-key`属性来控制选中的`badge` -:::demo 基础用法 ```html @@ -72,8 +36,6 @@ export default { } }; ``` -::: - ### BadgeGroup API diff --git a/docs/examples-docs/zh-CN/button.md b/docs/markdown/zh-CN/button.md similarity index 73% rename from docs/examples-docs/zh-CN/button.md rename to docs/markdown/zh-CN/button.md index f434a719212..b9715e8a527 100644 --- a/docs/examples-docs/zh-CN/button.md +++ b/docs/markdown/zh-CN/button.md @@ -1,29 +1,3 @@ - - ## Button 按钮 ### 使用指南 @@ -39,74 +13,62 @@ Vue.component(Button.name, Button); 支持`default`、`primary`、`danger`三种类型,默认为`default` -:::demo 按钮类型 ```html Default Primary Danger ``` -::: #### 按钮尺寸 支持`large`、`normal`、`small`、`mini`四种尺寸,默认为`normal` -:::demo 按钮尺寸 ```html Large Normal Small Mini ``` -::: #### 禁用状态 通过`disabled`属性来禁用按钮,此时按钮不可点击 -:::demo 禁用状态 ```html Diabled ``` -::: #### 加载状态 -:::demo 加载状态 ```html ``` -::: #### 自定义按钮标签 按钮标签默认为`button`,可以使用`tag`属性来修改按钮标签 -:::demo 自定义按钮标签 ```html - a 标签按钮 + 按钮 ``` -::: #### 页面底部操作按钮 -:::demo 页面底部操作按钮 ```html -立即购买 +按钮 - 加入购物车 + 按钮 - 立即购买 + 按钮 ``` -::: ### API diff --git a/docs/examples-docs/zh-CN/card.md b/docs/markdown/zh-CN/card.md similarity index 71% rename from docs/examples-docs/zh-CN/card.md rename to docs/markdown/zh-CN/card.md index a018bc09b6b..68d13f7a17a 100644 --- a/docs/examples-docs/zh-CN/card.md +++ b/docs/markdown/zh-CN/card.md @@ -1,13 +1,3 @@ - - ## Card 卡片 ### 使用指南 @@ -21,37 +11,33 @@ Vue.component(Card.name, Card); #### 基础用法 -:::demo 基础用法 ```html ``` -::: #### 高级用法 可以通过具名`slot`添加定制内容 -:::demo 高级用法 ```html
    - 按钮一 - 按钮二 + 按钮 + 按钮
    ``` -::: ### API diff --git a/docs/examples-docs/zh-CN/cell-swipe.md b/docs/markdown/zh-CN/cell-swipe.md similarity index 64% rename from docs/examples-docs/zh-CN/cell-swipe.md rename to docs/markdown/zh-CN/cell-swipe.md index e08ceadeb89..4cabcc0bb3f 100644 --- a/docs/examples-docs/zh-CN/cell-swipe.md +++ b/docs/markdown/zh-CN/cell-swipe.md @@ -1,21 +1,3 @@ - ## CellSwipe 滑动单元格 ### 使用指南 @@ -29,17 +11,15 @@ Vue.component(CellSwipe.name, CellSwipe); #### 基础用法 -:::demo 基础用法 ```html 选择 - + 删除 ``` -::: ### API diff --git a/docs/examples-docs/zh-CN/cell.md b/docs/markdown/zh-CN/cell.md similarity index 65% rename from docs/examples-docs/zh-CN/cell.md rename to docs/markdown/zh-CN/cell.md index 836deac4763..c942c90ed6c 100644 --- a/docs/examples-docs/zh-CN/cell.md +++ b/docs/markdown/zh-CN/cell.md @@ -1,28 +1,3 @@ - - - - ## Cell 单元格 ### 使用指南 @@ -39,69 +14,61 @@ Vue.component(CellGroup.name, CellGroup); 将`van-cell-group`组件看成一个容器即可 -:::demo 基础用法 ```html - - + + ``` -::: #### 只设置value 只设置`value`时会向左对齐 -:::demo 只设置value ```html - + ``` -::: #### 展示图标 通过`icon`属性在标题左侧展示图标 -:::demo 展示图标 + ```html ``` -::: + #### 展示箭头 传入`isLink`属性则会在右侧显示箭头 -:::demo 展示箭头 ```html - - + + ``` -::: #### 高级用法 如以上用法不能满足你的需求,可以使用对应的`slot`来自定义显示的内容 -:::demo 高级用法 ```html - + - - + + ``` -::: ### API diff --git a/docs/examples-docs/zh-CN/changelog-generated.md b/docs/markdown/zh-CN/changelog-generated.md similarity index 100% rename from docs/examples-docs/zh-CN/changelog-generated.md rename to docs/markdown/zh-CN/changelog-generated.md diff --git a/docs/examples-docs/zh-CN/changelog.md b/docs/markdown/zh-CN/changelog.md similarity index 99% rename from docs/examples-docs/zh-CN/changelog.md rename to docs/markdown/zh-CN/changelog.md index 5a31a5180a7..b69b29b9d55 100644 --- a/docs/examples-docs/zh-CN/changelog.md +++ b/docs/markdown/zh-CN/changelog.md @@ -4,12 +4,10 @@ `2017-11-15` **Improvements** - -- Icon: 增加几个新 icons [\#315](https://github.com/youzan/vant/pull/315) ([cookfront](https://github.com/cookfront)) +- Icon: 增加几个新 icons [\#315](https://github.com/youzan/vant/pull/315) [@cookfront](https://github.com/cookfront) **Bug Fixes** - -- Search: 修复 box-sizing wrong [\#312](https://github.com/youzan/vant/pull/312) ([chenjiahan](https://github.com/chenjiahan)) +- Search: 修复 box-sizing 错误 [\#312](https://github.com/youzan/vant/pull/312) [@chenjiahan](https://github.com/chenjiahan) ### [0.10.8](https://github.com/youzan/vant/tree/v0.10.8) `2017-11-11` diff --git a/docs/examples-docs/zh-CN/checkbox.md b/docs/markdown/zh-CN/checkbox.md similarity index 72% rename from docs/examples-docs/zh-CN/checkbox.md rename to docs/markdown/zh-CN/checkbox.md index 3be84ba8d89..cd220c5ec3d 100644 --- a/docs/examples-docs/zh-CN/checkbox.md +++ b/docs/markdown/zh-CN/checkbox.md @@ -1,33 +1,3 @@ - - - - ## Checkbox 复选框 ### 使用指南 @@ -43,35 +13,30 @@ Vue.component(CheckboxGroup.name, CheckboxGroup); #### 基础用法 通过`v-model`绑定 checkbox 的勾选状态 -:::demo 基础用法 ```html -复选框 1 +复选框 1 ``` ```javascript export default { data() { return { - checkbox1: true + checked: true }; } }; ``` -::: #### 禁用状态 -:::demo 禁用状态 ```html -复选框 2 +复选框 2 ``` -::: #### Checkbox 组 需要与`van-checkbox-group`一起使用,选中值是一个数组,通过`v-model`绑定在`van-checkbox-group`上,数组中的项即为选中的`Checkbox`的`name`属性设置的值 -:::demo Checkbox 组 ```html - 复选框{{ item }} + 复选框 {{ item }} ``` -```javascript -export default { - data() { - return { - list: ['a', 'b', 'c'], - result: ['a', 'b'] - }; - } -}; -``` -::: - ### Checkbox API | 参数 | 说明 | 类型 | 默认值 | 可选值 | diff --git a/docs/examples-docs/zh-CN/contact.md b/docs/markdown/zh-CN/contact.md similarity index 73% rename from docs/examples-docs/zh-CN/contact.md rename to docs/markdown/zh-CN/contact.md index f32f46aa0e8..cd50b857be8 100644 --- a/docs/examples-docs/zh-CN/contact.md +++ b/docs/markdown/zh-CN/contact.md @@ -1,79 +1,3 @@ - - - - ## Contact 联系人 通过 Contact 组件可以实现联系人的展示、选择、编辑等功能。 @@ -90,7 +14,6 @@ Vue.component(ContactEdit.name, ContactEdit); #### 基础用法 -:::demo 基础用法 ```html +/> @@ -114,8 +37,8 @@ Vue.component(ContactEdit.name, ContactEdit); @@ -194,7 +117,7 @@ export default { } }; ``` -::: + ### ContactCard API | 参数 | 说明 | 类型 | 默认值 | 可选值 | diff --git a/docs/examples-docs/zh-CN/coupon.md b/docs/markdown/zh-CN/coupon.md similarity index 72% rename from docs/examples-docs/zh-CN/coupon.md rename to docs/markdown/zh-CN/coupon.md index 92048fb5768..18e16e83ccf 100644 --- a/docs/examples-docs/zh-CN/coupon.md +++ b/docs/markdown/zh-CN/coupon.md @@ -1,71 +1,3 @@ - - - - ## Coupon 优惠券选择器 ### 使用指南 @@ -80,24 +12,23 @@ Vue.component(CouponList.name, CouponList); #### 基础用法 -:::demo 基础用法 ```html +/> + /> ``` @@ -135,7 +66,7 @@ export default { } } ``` -::: + ### CouponCell API diff --git a/docs/examples-docs/zh-CN/datetime-picker.md b/docs/markdown/zh-CN/datetime-picker.md similarity index 74% rename from docs/examples-docs/zh-CN/datetime-picker.md rename to docs/markdown/zh-CN/datetime-picker.md index 7d664da50ef..a9c0116afff 100644 --- a/docs/examples-docs/zh-CN/datetime-picker.md +++ b/docs/markdown/zh-CN/datetime-picker.md @@ -1,21 +1,3 @@ - - ## DatetimePicker 时间选择 ### 使用指南 @@ -29,15 +11,14 @@ Vue.component(DatetimePicker.name, DatetimePicker); #### 基础用法 -:::demo 基础用法 ```html ``` @@ -54,36 +35,30 @@ export default { } }; ``` -::: #### 选择日期 -:::demo 选择日期 ```html ``` -::: #### 选择时间 -:::demo 选择时间 ```html ``` -::: - ### API diff --git a/docs/markdown/zh-CN/dialog.md b/docs/markdown/zh-CN/dialog.md new file mode 100644 index 00000000000..eac30892cb7 --- /dev/null +++ b/docs/markdown/zh-CN/dialog.md @@ -0,0 +1,63 @@ +## Dialog 弹出框 + +### 使用指南 + +```js +import { Dialog } from 'vant'; +``` + +### 代码演示 + +#### 消息提示 +用于提示一些消息,只包含一个确认按钮 + +```javascript +Dialog.alert({ + title: '标题', + message: '弹窗内容' +}).then(() => { + // on close +}); + +Dialog.alert({ + message: '弹窗内容' +}).then(() => { + // on close +}); +``` + +#### 消息确认 +用于确认消息,包含取消和确认按钮 + +```javascript +Dialog.confirm({ + title: '标题', + message: '弹窗内容' +}).then(() => { + // on confirm +}).catch(() => { + // on cancel +}); +``` + +### 方法 + +| 方法名 | 参数 | 返回值 | 介绍 | +|-----------|-----------|-----------|-------------| +| Dialog.alert | options | `Promise` | 展示消息提示弹窗 | +| Dialog.confirm | options | `Promise` | 展示消息确认弹窗 | +| Dialog.close | - | `void` | 关闭弹窗 | + +### Options + +| 参数 | 说明 | 类型 | 默认值 | 可选值 | +|-----------|-----------|-----------|-------------|-------------| +| title | 标题 | `String` | - | - | +| message | 内容 | `String` | - | - | +| showConfirmButton | 是否展示确认按钮 | `Boolean` | `true` | - | +| showCancelButton | 是否展示取消按钮 | `Boolean` | `false` | - | +| confirmButtonText | 确认按钮的文案 | `String` | `确认` | - | +| cancelButtonText | 取消按钮的文案 | `String` | `取消` | - | +| overlay | 是否展示蒙层 | `Boolean` | `true` | - | +| closeOnClickOverlay | 点击蒙层时是否关闭弹窗 | `Boolean` | `false` | - | +| lockOnScroll | 是否禁用背景滚动 | `Boolean` | `true` | - | diff --git a/docs/examples-docs/zh-CN/field.md b/docs/markdown/zh-CN/field.md similarity index 87% rename from docs/examples-docs/zh-CN/field.md rename to docs/markdown/zh-CN/field.md index ae9d029a4e6..afa97414661 100644 --- a/docs/examples-docs/zh-CN/field.md +++ b/docs/markdown/zh-CN/field.md @@ -1,22 +1,3 @@ - - - - ## Field 输入框 `input`或`textarea`的输入框。 @@ -33,18 +14,15 @@ Vue.component(Field.name, Field); #### 基础用法 通过 v-model 绑定输入框的值 -:::demo 基础用法 ```html ``` -::: #### 自定义类型 根据`type`属性定义不同类型的输入框 -:::demo 自定义类型 ```html ``` -::: #### 禁用输入框 -:::demo 禁用输入框 ```html ``` -::: #### 错误提示 -:::demo 错误提示 ```html ``` -::: #### 高度自适应 对于 textarea,可以通过`autosize`属性设置高度自适应 -:::demo 高度自适应 ```html ``` -::: ### API diff --git a/docs/examples-docs/zh-CN/goods-action.md b/docs/markdown/zh-CN/goods-action.md similarity index 83% rename from docs/examples-docs/zh-CN/goods-action.md rename to docs/markdown/zh-CN/goods-action.md index 04fd34455e7..11689051c6d 100644 --- a/docs/examples-docs/zh-CN/goods-action.md +++ b/docs/markdown/zh-CN/goods-action.md @@ -1,26 +1,3 @@ - - - - ## GoodsAction 商品页行动点 ### 使用指南 @@ -38,7 +15,6 @@ Vue.component(GoodsActionMiniBtn.name, GoodsActionMiniBtn); ### 代码演示 -:::demo ```html @@ -68,7 +44,6 @@ export default { } } ``` -::: ### API diff --git a/docs/markdown/zh-CN/icon.md b/docs/markdown/zh-CN/icon.md new file mode 100644 index 00000000000..b92eb7a056f --- /dev/null +++ b/docs/markdown/zh-CN/icon.md @@ -0,0 +1,23 @@ +## Icon 图标 + +### 使用指南 +``` javascript +import { Icon } from 'vant'; + +Vue.component(Icon.name, Icon); +``` + +### 代码演示 + +#### 基础用法 +设置`name`属性为对应的图标名称即可,所有可用的图标名称见右侧列表 + +```html + +``` + +### API + +| 参数 | 说明 | 类型 | 默认值 | 可选值 | +|-----------|-----------|-----------|-------------|-------------| +| name | icon名称 | `String` | `''` | - | diff --git a/docs/markdown/zh-CN/image-preview.md b/docs/markdown/zh-CN/image-preview.md new file mode 100644 index 00000000000..53996532320 --- /dev/null +++ b/docs/markdown/zh-CN/image-preview.md @@ -0,0 +1,36 @@ +## ImagePreview 图片预览 + +### 使用指南 + +`ImagePreview`和其他组件不同,不是通过HTML结构的方式来使用,而是通过函数调用的方式。使用前需要先引入它。 + +```js +import { ImagePreview } from 'vant'; +``` + +### 代码演示 + +#### 基础用法 + +```javascript +ImagePreview([ + 'https://img.yzcdn.cn/1.jpg', + 'https://img.yzcdn.cn/2.jpg' +]); +``` + +#### 指定初始位置 + +```javascript +ImagePreview([ + 'https://img.yzcdn.cn/1.jpg', + 'https://img.yzcdn.cn/2.jpg' +], 1); +``` + +### 方法参数 + +| 参数名 | 说明 | 类型 | +|-----------|-----------|-----------| +| imageUrls | 需要预览的图片 | `Array` | +| startPosition | 图片预览起始位置索引 | `Number` | diff --git a/docs/examples-docs/zh-CN/layout.md b/docs/markdown/zh-CN/layout.md similarity index 79% rename from docs/examples-docs/zh-CN/layout.md rename to docs/markdown/zh-CN/layout.md index 9256c40b090..c9a01eb4ace 100644 --- a/docs/examples-docs/zh-CN/layout.md +++ b/docs/markdown/zh-CN/layout.md @@ -1,27 +1,3 @@ - - ## Layout 布局 提供了`van-row`和`van-col`两个组件来进行行列布局 @@ -41,7 +17,6 @@ Vue.component(Col.name, Col); Layout 组件提供了`24列栅格`,通过在`Col`上添加`span`属性设置列所占的宽度百分比 此外,添加`offset`属性可以设置列的偏移宽度,计算方式与 span 相同 -:::demo 基本用法 ```html span: 8 @@ -58,13 +33,11 @@ Layout 组件提供了`24列栅格`,通过在`Col`上添加`span`属性设置 offset: 12, span: 12 ``` -::: #### 设置列元素间距 通过`gutter`属性可以设置列元素之间的间距,默认间距为 0 -:::demo 在列元素之间增加间距 ```html span: 8 @@ -72,7 +45,6 @@ Layout 组件提供了`24列栅格`,通过在`Col`上添加`span`属性设置 span: 8 ``` -::: ### API diff --git a/docs/markdown/zh-CN/lazyload.md b/docs/markdown/zh-CN/lazyload.md new file mode 100644 index 00000000000..a6b23549591 --- /dev/null +++ b/docs/markdown/zh-CN/lazyload.md @@ -0,0 +1,67 @@ +## Lazyload 图片懒加载 + +### 使用指南 + +`Lazyload`是`Vue`指令,所以需要使用它必须将它注册到`Vue`的指令中。 + +```js +import Vue from 'vue'; +import { Lazyload } from 'vant'; + +Vue.use(Lazyload, options); +``` + +### 代码演示 + +#### 基础用法 +将`v-lazy`指令的值设置为你需要懒加载的图片 + +```html + +``` + +```javascript +export default { + data() { + return { + imageList: [ + 'https://img.yzcdn.cn/1.jpg', + 'https://img.yzcdn.cn/2.jpg' + ] + }; + } +} +``` + +#### 背景图懒加载 + +和图片懒加载不同,背景图懒加载需要使用`v-lazy:background-image`,值设置为背景图片的地址,需要注意的是必须声明容器高度。 + +```html +
    +``` + +#### 懒加载模块 + +懒加载模块需要使用到`lazy-component`,将需要懒加载的内容放在`lazy-component`中即可。 + +```html + + + +``` + +### Options + +| 参数 | 说明 | 类型 | 默认值 | 可选值 | +|-----------|-----------|-----------|-------------|-------------| +| loading | 加载时的图片 | `String` | - | - | +| error | 错误时的图片 | `String` | - | - | +| preload | 预加载高度的比例 | `String` | - | - | +| attempt | 尝试次数 | `Number` | `3` | - | +| listenEvents | 监听的事件 | `Array` | `scroll`等 | - | +| adapter | 适配器 | `Object` | - | - | +| filter | 图片url过滤 | `Object` | - | - | +| lazyComponent | 是否能懒加载模块 | `Boolean` | `false` | - | + +更多内容请参照:[ vue-lazyload 官方文档](https://github.com/hilongjw/vue-lazyload) diff --git a/docs/markdown/zh-CN/loading.md b/docs/markdown/zh-CN/loading.md new file mode 100644 index 00000000000..dda2c6e0301 --- /dev/null +++ b/docs/markdown/zh-CN/loading.md @@ -0,0 +1,38 @@ +## Loading 加载 + +### 使用指南 +``` javascript +import { Loading } from 'vant'; + +Vue.component(Loading.name, Loading); +``` + +### 代码演示 + +#### 单色圆环 + +```html + + +``` + +#### 渐变色圆环 + +```html + + +``` + +#### Spinner + +```html + + +``` + +### API + +| 参数 | 说明 | 类型 | 默认值 | 可选值 | +|-----------|-----------|-----------|-------------|-------------| +| color | 颜色 | `String` | `black` | `black` `white` | +| type | 类型 | `String` | `gradient-circle` | `spinner` `circle` | diff --git a/docs/examples-docs/zh-CN/nav-bar.md b/docs/markdown/zh-CN/nav-bar.md similarity index 67% rename from docs/examples-docs/zh-CN/nav-bar.md rename to docs/markdown/zh-CN/nav-bar.md index cfa355e7093..ae5c48feac3 100644 --- a/docs/examples-docs/zh-CN/nav-bar.md +++ b/docs/markdown/zh-CN/nav-bar.md @@ -11,36 +11,32 @@ Vue.component(NavBar.name, NavBar); #### 基础用法 -:::demo 基础用法 ```html ``` -::: #### 高级用法 通过 slot 定制内容 -:::demo 高级用法 ```html - + ``` -::: ### API | 参数 | 说明 | 类型 | 默认值 | 可选值 | |-----------|-----------|-----------|-------------|-------------| | title | 标题 | `String` | `''` | - | -| left-text | 左侧文案 | `String` | `''` | - | -| right-text | 右侧文案 | `String` | `''` | - | -| left-arrow | 是否显示左侧箭头 | `Boolean` | `false` | - | +| leftText | 左侧文案 | `String` | `''` | - | +| rightText | 右侧文案 | `String` | `''` | - | +| leftArrow | 是否显示左侧箭头 | `Boolean` | `false` | - | | fixed | 是否固定在顶部 | `Boolean` | `false` | - | ### Slot diff --git a/docs/examples-docs/zh-CN/notice-bar.md b/docs/markdown/zh-CN/notice-bar.md similarity index 84% rename from docs/examples-docs/zh-CN/notice-bar.md rename to docs/markdown/zh-CN/notice-bar.md index 4eaeccbfb96..b96abfd98aa 100644 --- a/docs/examples-docs/zh-CN/notice-bar.md +++ b/docs/markdown/zh-CN/notice-bar.md @@ -1,11 +1,3 @@ - - ## NoticeBar 通告栏 ### 使用指南 @@ -19,31 +11,25 @@ Vue.component(NoticeBar.name, NoticeBar); #### 基础用法 -:::demo 基础用法 ```html - ``` -::: #### 禁用滚动 文字内容多于一行时,可通过`scrollable`参数控制是否开启滚动 -:::demo 禁用滚动 ```html 足协杯战线连续第2年上演广州德比战,上赛季半决赛上恒大以两回合5-3的总比分淘汰富力。 ``` -::: #### 通告栏模式 默认模式为空,支持`closeable`和`link`。 -:::demo 通告栏模式 ```html @@ -55,7 +41,6 @@ Vue.component(NoticeBar.name, NoticeBar); 足协杯战线连续第2年上演广州德比战,上赛季半决赛上恒大以两回合5-3的总比分淘汰富力。 ``` -::: ### API diff --git a/docs/examples-docs/zh-CN/number-keyboard.md b/docs/markdown/zh-CN/number-keyboard.md similarity index 80% rename from docs/examples-docs/zh-CN/number-keyboard.md rename to docs/markdown/zh-CN/number-keyboard.md index 427a12c7e43..fe0fed0a543 100644 --- a/docs/examples-docs/zh-CN/number-keyboard.md +++ b/docs/markdown/zh-CN/number-keyboard.md @@ -1,32 +1,3 @@ - - - - ## NumberKeyboard 数字键盘 ### 使用指南 @@ -40,7 +11,6 @@ Vue.component(NumberKeyboard.name, NumberKeyboard); #### 基础用法 -:::demo 基础用法 ```html 弹出键盘 @@ -76,8 +46,6 @@ export default { } } ``` -::: - ### API diff --git a/docs/examples-docs/zh-CN/panel.md b/docs/markdown/zh-CN/panel.md similarity index 58% rename from docs/examples-docs/zh-CN/panel.md rename to docs/markdown/zh-CN/panel.md index b4647334c05..6657748a854 100644 --- a/docs/examples-docs/zh-CN/panel.md +++ b/docs/markdown/zh-CN/panel.md @@ -1,19 +1,3 @@ - - ## Panel 面板 ### 使用指南 @@ -28,28 +12,24 @@ Vue.component(Panel.name, Panel); #### 基础用法 面板只是一个容器,里面可以放入自定义的内容 -:::demo 基础用法 ```html - -
    Panel内容
    + +
    内容
    ``` -::: #### 高级用法 使用`slot`自定义内容 -:::demo 高级用法 ```html - -
    Panel内容
    + +
    内容
    - 按钮一 - 按钮二 + 按钮 + 按钮
    ``` -::: ### API @@ -59,7 +39,6 @@ Vue.component(Panel.name, Panel); | desc | 描述 | `String` | - | - | | status | 状态 | `String` | - | - | - ### Slot | name | 描述 | diff --git a/docs/examples-docs/zh-CN/password-input.md b/docs/markdown/zh-CN/password-input.md similarity index 78% rename from docs/examples-docs/zh-CN/password-input.md rename to docs/markdown/zh-CN/password-input.md index 56ddb58b44e..70313ba0b2a 100644 --- a/docs/examples-docs/zh-CN/password-input.md +++ b/docs/markdown/zh-CN/password-input.md @@ -1,23 +1,3 @@ - - ## PasswordInput 密码输入框 密码输入框组件通常与 [数字键盘](#/zh-CN/component/number-keyboard) 组件配合使用 @@ -33,14 +13,13 @@ Vue.component(NumberKeyBoard.name, NumberKeyBoard); #### 基础用法 -:::demo 基础用法 ```html +/> +/> ``` ```javascript @@ -57,7 +36,7 @@ export default { return { value: '', showKeyboard: true - } + }; }, methods: { @@ -70,7 +49,6 @@ export default { } } ``` -::: ### API diff --git a/docs/examples-docs/zh-CN/picker.md b/docs/markdown/zh-CN/picker.md similarity index 53% rename from docs/examples-docs/zh-CN/picker.md rename to docs/markdown/zh-CN/picker.md index e02b85dad29..83a4ff41a4a 100644 --- a/docs/examples-docs/zh-CN/picker.md +++ b/docs/markdown/zh-CN/picker.md @@ -1,43 +1,3 @@ - - ## Picker 选择器 ### 使用指南 @@ -51,16 +11,14 @@ Vue.component(Picker.name, Picker); #### 基础用法 -:::demo 基础用法 ```html - + ``` ```javascript const citys = { - '浙江': ['杭州', '宁波', '温州', '嘉兴', '湖州', '绍兴', '金华', '衢州', '舟山', '台州', '丽水'], - '福建': ['福州', '厦门', '莆田', '三明', '泉州', '漳州', '南平', '龙岩', '宁德'], - '湖南': ['长沙', '株洲', '湘潭', '衡阳', '邵阳', '岳阳', '常德', '张家界', '益阳', '郴州', '永州', '怀化', '娄底', '湘西土家族苗族自治州'] + '浙江': ['杭州', '宁波', '温州', '嘉兴', '湖州', '绍兴', '金华', '衢州'], + '福建': ['福州', '厦门', '莆田', '三明', '泉州', '漳州', '南平', '龙岩'] }; export default { @@ -72,7 +30,7 @@ export default { className: 'column1' }, { - values: ['杭州', '宁波', '温州', '嘉兴', '湖州', '绍兴', '金华', '衢州', '舟山', '台州', '丽水'], + values: citys['浙江'], className: 'column2' } ] @@ -80,33 +38,30 @@ export default { }, methods: { - handlePickerChange(picker, values) { + onChange(picker, values) { picker.setColumnValues(1, citys[values[0]]); } } }; ``` -::: -#### 带toolbar的Picker +#### 带 toolbar 的 Picker -:::demo 带toolbar的Picker ```html + @change="onChange" + @cancel="onCancel" + @confirm="onConfirm" +/> ``` ```javascript const citys = { - '浙江': ['杭州', '宁波', '温州', '嘉兴', '湖州', '绍兴', '金华', '衢州', '舟山', '台州', '丽水'], - '福建': ['福州', '厦门', '莆田', '三明', '泉州', '漳州', '南平', '龙岩', '宁德'], - '湖南': ['长沙', '株洲', '湘潭', '衡阳', '邵阳', '岳阳', '常德', '张家界', '益阳', '郴州', '永州', '怀化', '娄底', '湘西土家族苗族自治州'] + '浙江': ['杭州', '宁波', '温州', '嘉兴', '湖州', '绍兴', '金华', '衢州'], + '福建': ['福州', '厦门', '莆田', '三明', '泉州', '漳州', '南平', '龙岩'] }; export default { @@ -119,7 +74,7 @@ export default { className: 'column1' }, { - values: ['杭州', '宁波', '温州', '嘉兴', '湖州', '绍兴', '金华', '衢州', '舟山', '台州', '丽水'], + values: citys['浙江'], className: 'column2' } ] @@ -127,19 +82,18 @@ export default { }, methods: { - handlePickerChange(picker, values) { + onChange(picker, values) { picker.setColumnValues(1, citys[values[0]]); }, - handlePickerCancel() { - alert('picker cancel'); + onCancel() { + Toast('picker cancel'); }, - handlePickerConfirm() { - alert('picker confirm'); + onConfirm() { + Toast('picker confirm'); } } }; ``` -::: ### API diff --git a/docs/markdown/zh-CN/popup.md b/docs/markdown/zh-CN/popup.md new file mode 100644 index 00000000000..7492131b101 --- /dev/null +++ b/docs/markdown/zh-CN/popup.md @@ -0,0 +1,48 @@ +## Popup 弹出层 + +### 使用指南 +``` javascript +import { Popup } from 'vant'; + +Vue.component(Popup.name, Popup); +``` + +### 代码演示 + +#### 基础用法 +`popup`默认从中间弹出 + +```html +内容 +``` + +```javascript +export default { + data() { + return { + show: false + } + } +}; +``` + +#### 弹出位置 +通过`position`属性设置 Popup 弹出位置 + +```html + + 内容 + +``` + +### API + +| 参数 | 说明 | 类型 | 默认值 | 可选值 | +|-----------|-----------|-----------|-------------|-------------| +| v-model | 当前组件是否显示 | `Boolean` | `false` | - | +| overlay | 是否显示背景遮罩层 | `Boolean` | `true` | - | +| lockOnScroll | 背景是否跟随滚动 | `Boolean` | `false` | - | +| position | 弹出层位置 | `String` | - | `top` `bottom` `right` `left` | +| closeOnClickOverlay | 点击遮罩层是否关闭弹出层 | `Boolean` | `true` | - | +| transition | 弹出层的`transition` | `String` | `popup-slide` | - | +| preventScroll | 是否防止滚动穿透 | `Boolean` | `false` | - | diff --git a/docs/examples-docs/zh-CN/progress.md b/docs/markdown/zh-CN/progress.md similarity index 50% rename from docs/examples-docs/zh-CN/progress.md rename to docs/markdown/zh-CN/progress.md index 1f7a0314ca1..d31c09377a6 100644 --- a/docs/examples-docs/zh-CN/progress.md +++ b/docs/markdown/zh-CN/progress.md @@ -1,11 +1,3 @@ - - ## Progress 进度条 ### 使用指南 @@ -21,37 +13,31 @@ Vue.component(Progress.name, Progress); 进度条默认为蓝色,使用`percentage`属性来设置当前进度 -:::demo 基础用法 ```html - - - + + + ``` -::: #### 进度条置灰 -:::demo 进度条置灰 ```html - - - + + + ``` -::: #### 样式定制 -可以使用`pivot-text`属性自定义文字,`color`属性自定义进度条颜色 +可以使用`pivotText`属性自定义文字,`color`属性自定义进度条颜色 -:::demo 样式定制 ```html - - - + + + ``` -::: ### API diff --git a/docs/examples-docs/zh-CN/pull-refresh.md b/docs/markdown/zh-CN/pull-refresh.md similarity index 61% rename from docs/examples-docs/zh-CN/pull-refresh.md rename to docs/markdown/zh-CN/pull-refresh.md index 3326d651db4..cb6ad0f7dac 100644 --- a/docs/examples-docs/zh-CN/pull-refresh.md +++ b/docs/markdown/zh-CN/pull-refresh.md @@ -1,55 +1,3 @@ - - - - ## PullRefresh 下拉刷新 ### 使用指南 @@ -61,7 +9,6 @@ Vue.component(PullRefresh.name, PullRefresh); ### 代码演示 -:::demo ```html @@ -91,7 +38,6 @@ export default { } } ``` -::: ### API diff --git a/docs/examples-docs/zh-CN/quickstart.md b/docs/markdown/zh-CN/quickstart.md similarity index 100% rename from docs/examples-docs/zh-CN/quickstart.md rename to docs/markdown/zh-CN/quickstart.md diff --git a/docs/examples-docs/zh-CN/radio.md b/docs/markdown/zh-CN/radio.md similarity index 50% rename from docs/examples-docs/zh-CN/radio.md rename to docs/markdown/zh-CN/radio.md index 8823f92dde5..2bea771d378 100644 --- a/docs/examples-docs/zh-CN/radio.md +++ b/docs/markdown/zh-CN/radio.md @@ -1,28 +1,3 @@ - - - - ## Radio 单选框 ### 使用指南 @@ -38,97 +13,55 @@ Vue.component(Radio.name, Radio); 通过`v-model`绑定值即可。当`Radio`选中时,绑定的值即为`Radio`中`name`属性设置的值。 -:::demo 基础用法 ```html -
    - 单选框 1 - 单选框 2 -
    +单选框 1 +单选框 2 ``` + ```javascript export default { data() { return { - radio1: '1' + radio: '1' } } }; ``` -::: #### 禁用状态 设置`disabled`属性即可,此时`Radio`不能点击。 -:::demo 禁用状态 ```html -
    - 未选中禁用 - 选中且禁用 -
    +未选中禁用 +选中且禁用 ``` -```javascript -export default { - data() { - return { - radio2: '2' - } - } -}; -``` -::: -#### radio组 +#### Radio 组 需要与`van-radio-group`一起使用,在`van-radio-group`通过`v-model`来绑定当前选中的值。例如下面的`radio3`: -:::demo radio组 ```html -
    - - 单选框 1 - 单选框 2 - -
    -``` - -```javascript -export default { - data() { - return { - radio3: '1' - } - } -}; + + 单选框 1 + 单选框 2 + ``` -::: #### 与 Cell 组件一起使用 此时你需要再引入`Cell`和`CellGroup`组件。 -:::demo 与 Cell 组件一起使用 ```html - + - 单选框1 - 单选框2 + 单选框 1 + 单选框 2 ``` -```javascript -export default { - data() { - return { - radio4: '1' - } - } -}; -``` -::: - ### Radio API | 参数 | 说明 | 类型 | 默认值 | 可选值 | diff --git a/docs/examples-docs/zh-CN/search.md b/docs/markdown/zh-CN/search.md similarity index 76% rename from docs/examples-docs/zh-CN/search.md rename to docs/markdown/zh-CN/search.md index a4c62a82b2f..baf4e5c65d2 100644 --- a/docs/examples-docs/zh-CN/search.md +++ b/docs/markdown/zh-CN/search.md @@ -1,32 +1,3 @@ - - - - ## Search 搜索 ### 使用指南 @@ -41,44 +12,38 @@ Vue.component(Search.name, Search); #### 基础用法 `van-search` 中,v-model 用于控制搜索框中的文字。background 可以自定义搜索框外部背景色。 -:::demo 基础用法 ```html - + ``` -::: #### 监听对应事件 `van-search` 提供了 search 和 cancel 事件。search 事件在用户点击键盘上的 搜索/回车 按钮触发。cancel 事件在用户点击搜索框右侧取消按钮时触发 Tips: 在 `van-search` 外层增加 form 标签,并且 action 不为空,即可在 IOS 弹出的输入法中显示搜索按钮 -:::demo 监听对应事件 ```html
    ``` -::: #### 自定义行动按钮 `van-search` 支持自定义右侧取消按钮,使用名字为 action 的 slot 即可。使用此 slot 以后,原有的 cancel 事件不再生效。 -:::demo 自定义行动按钮 ```html
    搜索
    ``` -::: ### API diff --git a/docs/examples-docs/zh-CN/sku.md b/docs/markdown/zh-CN/sku.md similarity index 65% rename from docs/examples-docs/zh-CN/sku.md rename to docs/markdown/zh-CN/sku.md index 80d642f94e5..022101b9436 100644 --- a/docs/examples-docs/zh-CN/sku.md +++ b/docs/markdown/zh-CN/sku.md @@ -1,50 +1,5 @@ ## Sku 商品购买组件 - - - - ### 使用指南 ```javascript import { Sku } from 'vant'; @@ -54,70 +9,58 @@ Vue.component(Sku.name, Sku); ### 代码演示 #### 基础用法 -:::demo + ```html - + ``` -::: -#### 自定义sku slot区块 -:::demo +#### 自定义 sku slot 区块 + ```html - + + + + + + ``` -::: + ### API diff --git a/docs/examples-docs/zh-CN/stepper.md b/docs/markdown/zh-CN/stepper.md similarity index 74% rename from docs/examples-docs/zh-CN/stepper.md rename to docs/markdown/zh-CN/stepper.md index fe24b38b211..8034518f78c 100644 --- a/docs/examples-docs/zh-CN/stepper.md +++ b/docs/markdown/zh-CN/stepper.md @@ -1,22 +1,3 @@ - - - - ## Stepper 步进器 ### 使用指南 @@ -30,9 +11,8 @@ Vue.component(Stepper.name, Stepper); #### 基础用法 -:::demo 基础用法 ```html - + ``` ```javascript @@ -44,26 +24,21 @@ export default { } } ``` -::: #### 禁用状态 通过设置`disabled`属性来禁用 stepper -:::demo 禁用状态 ```html - + ``` -::: #### 高级用法 默认是每次加减为1,可以对组件设置`step`、`min`、`max`、`defaultValue`属性 -:::demo 高级用法 ```html - + ``` -::: ### API diff --git a/docs/examples-docs/zh-CN/steps.md b/docs/markdown/zh-CN/steps.md similarity index 60% rename from docs/examples-docs/zh-CN/steps.md rename to docs/markdown/zh-CN/steps.md index 7a9f6412085..1c2f0608d4a 100644 --- a/docs/examples-docs/zh-CN/steps.md +++ b/docs/markdown/zh-CN/steps.md @@ -1,43 +1,3 @@ - - - - ## Steps 步骤条 ### 使用指南 @@ -52,7 +12,6 @@ Vue.component(Steps.name, Steps); #### 基础用法 -:::demo 基础用法 ```html 买家下单 @@ -60,8 +19,6 @@ Vue.component(Steps.name, Steps); 买家提货 交易完成 - -下一步 ``` ```javascript @@ -70,29 +27,20 @@ export default { return { active: 0 }; - }, - - methods: { - nextStep() { - this.active = ++this.active % 4; - } } } ``` -::: #### 物流描述 通过`title`和`description`属性来定义物流描述信息 -:::demo 物流描述 ```html 买家下单 商家接单 @@ -100,15 +48,12 @@ export default { 交易完成 ``` -::: #### 竖向步骤条 - 可以通过设置`direction`属性来改变步骤条的显示方式 -:::demo 竖向步骤条 ```html - +

    【城市】物流状态1

    2016-07-12 12:40

    @@ -123,23 +68,6 @@ export default {
    ``` -::: - -### 高级用法 -使用`slot`增加自定义内容 - -:::demo 高级用法 -```html - - -

    物流进度

    - 买家下单 - 商家接单 - 买家提货 - 交易完成 -
    -``` -::: ### Steps API diff --git a/docs/examples-docs/zh-CN/submit-bar.md b/docs/markdown/zh-CN/submit-bar.md similarity index 62% rename from docs/examples-docs/zh-CN/submit-bar.md rename to docs/markdown/zh-CN/submit-bar.md index 6d0617f2284..944ec64c5b5 100644 --- a/docs/examples-docs/zh-CN/submit-bar.md +++ b/docs/markdown/zh-CN/submit-bar.md @@ -1,31 +1,5 @@ ## SubmitBar 提交订单栏 - - - - ### 使用指南 ``` javascript import { SubmitBar } from 'vant'; @@ -37,67 +11,61 @@ Vue.component(SubmitBar.name, SubmitBar); #### 基础用法 -:::demo 基础用法 ```html ``` -::: #### 禁用状态 禁用状态下不会触发`submit`事件 -:::demo 禁用状态 ```html ``` -::: #### 加载状态 加载状态下不会触发`submit`事件 -:::demo 加载状态 + ```html ``` -::: -#### +#### 高级用法 提示文案中的额外操作和说明 -:::demo 提示文案中添加操作 + ```html - 您的收货地址不支持同城送, 修改地址 > + 您的收货地址不支持同城送, 修改地址 > ``` -::: ### API | 参数 | 说明 | 类型 | 默认值 | 必须 | |-----------|-----------|-----------|-------------|-------------| | price | 价格(单位分) | `Number` | - | 是 | -| button-text | 按钮文字 | `String` | - | 是 | -| button-type | 按钮类型 | `String` | `danger` | 否 | +| buttonText | 按钮文字 | `String` | - | 是 | +| buttonType | 按钮类型 | `String` | `danger` | 否 | | tip | 提示文案 | `String` | - | 否 | | disabled | 是否禁用按钮 | `Boolean` | `false` | 否 | | loading | 是否显示加载中的按钮 | `Boolean` | `false` | 否 | diff --git a/docs/examples-docs/zh-CN/swipe.md b/docs/markdown/zh-CN/swipe.md similarity index 57% rename from docs/examples-docs/zh-CN/swipe.md rename to docs/markdown/zh-CN/swipe.md index 5470707b8ad..eb7d480837e 100644 --- a/docs/examples-docs/zh-CN/swipe.md +++ b/docs/markdown/zh-CN/swipe.md @@ -1,54 +1,3 @@ - - - - ## Swipe 轮播 ### 使用指南 @@ -64,7 +13,6 @@ Vue.component(SwipeItem.name, SwipeItem); #### 基础用法 通过`autoplay`属性设置自动轮播间隔 -:::demo 基础用法 ```html 1 @@ -73,12 +21,10 @@ Vue.component(SwipeItem.name, SwipeItem); 4 ``` -::: #### 图片懒加载 配合 [Lazyload](#/zh-CN/component/lazyload) 组件实现图片懒加载 -:::demo 图片懒加载 ```html @@ -99,7 +45,6 @@ export default { } } ``` -::: ### API diff --git a/docs/examples-docs/zh-CN/switch-cell.md b/docs/markdown/zh-CN/switch-cell.md similarity index 79% rename from docs/examples-docs/zh-CN/switch-cell.md rename to docs/markdown/zh-CN/switch-cell.md index 3474e56c754..5064153e75d 100644 --- a/docs/examples-docs/zh-CN/switch-cell.md +++ b/docs/markdown/zh-CN/switch-cell.md @@ -2,16 +2,6 @@ `SwitchCell`组件是对`Switch`和`Cell`组件的封装 - - ### 使用指南 ``` javascript import { SwitchCell } from 'vant'; @@ -23,7 +13,7 @@ Vue.component(SwitchCell.name, SwitchCell); #### 基础用法 -:::demo 基础用法 + ```html @@ -39,29 +29,24 @@ export default { } } ``` -::: #### 禁用状态 通过`disabled`属性可以将组件设置为禁用状态 -:::demo 禁用状态 ```html - + ``` -::: #### 加载状态 通过`loading`属性可以将组件设置为加载状态 -:::demo 加载状态 ```html - + ``` -::: ### API diff --git a/docs/examples-docs/zh-CN/switch.md b/docs/markdown/zh-CN/switch.md similarity index 64% rename from docs/examples-docs/zh-CN/switch.md rename to docs/markdown/zh-CN/switch.md index 5511d5d6824..3d439c3283b 100644 --- a/docs/examples-docs/zh-CN/switch.md +++ b/docs/markdown/zh-CN/switch.md @@ -1,35 +1,3 @@ - - - - ## Switch 开关 ### 使用指南 @@ -42,8 +10,6 @@ Vue.component(Switch.name, Switch); ### 代码演示 #### 基础用法 - -:::demo 基础用法 ```html ``` @@ -57,32 +23,27 @@ export default { } }; ``` -::: #### 禁用状态 -:::demo 禁用状态 ```html ``` -::: #### 加载状态 -:::demo 加载状态 ```html ``` -::: #### 高级用法 -:::demo 高级用法 ```html - + ``` + ```js export default { data() { return { - checked2: true + checked: true }; }, @@ -92,13 +53,12 @@ export default { title: '提醒', message: '是否切换开关?' }).then(() => { - this.checked2 = checked; + this.checked = checked; }); } } }; ``` -::: ### API diff --git a/docs/markdown/zh-CN/tab.md b/docs/markdown/zh-CN/tab.md new file mode 100644 index 00000000000..5e750a0d3f0 --- /dev/null +++ b/docs/markdown/zh-CN/tab.md @@ -0,0 +1,129 @@ + + +## Tabs 标签页 + +### 使用指南 +``` javascript +import { Tab, Tabs } from 'vant'; + +Vue.component(Tab.name, Tab); +Vue.component(Tabs.name, Tabs); +``` + +### 代码演示 + +#### 基础用法 + +默认情况下启用第一个 tab,可以通过`active`属性激活对应特定索引的 tab + +```html + + + 内容 {{ index }} + + +``` + +```js +export default { + data() { + return { + active: 2 + }; + } +} +``` + +#### 横向滚动 + +默认情况下多于4个tab时,可以横向滚动tab。可以通过设置`swipeThreshold`这个阙值,多于这个阙值时,tab就会支持横向滚动。 + +```html + + + 内容 {{ index }} + + +``` + +#### 禁用标签 + +在对应的`van-tab`上设置`disabled`属性即可。如果需要监听禁用事件,可以在`van-tabs`上监听`disabled`事件。 + +```html + + + 内容 {{ index }} + + +``` + +```javascript +export default { + methods: { + onClickDisabled() { + Toast('Disabled!') + } + } +}; +``` + +#### 样式风格 + +`Tabs`目前有两种样式:`line`和`card`,默认为`line`样式,也就上面基础用法中的样式,你可以在`van-tabs`上设置`type`为`card`改为card样式。 + +```html + + + 内容 {{ index }} + + +``` + +#### 点击事件 + +可以在`van-tabs`上绑定一个`click`事件,事件处理函数有一个参数,参数为对应`tab`在`tabs`中的索引。 + +```html + + + 内容 {{ index }} + + +``` + +```javascript +export default { + methods: { + handleTabClick(index) { + Toast(index); + } + } +}; +``` + +### Tabs API + +| 参数 | 说明 | 类型 | 默认值 | 可选 | +|-----------|-----------|-----------|-------------|-------------| +| type | Tab 样式类型 | `String` | `line` | `card` | +| active | 默认激活的 tab | `String` `Number` | `0` | - | +| duration | 切换 tab 的动画时间 | `Number` | `0.3` | - | - | +| swipeThreshold | 滚动阀值,设置 Tab 超过多少个可滚动 | `Number` | `4` | - | - | + +### Tab API + +| 参数 | 说明 | 类型 | 默认值 | 可选 | +|-----------|-----------|-----------|-------------|-------------| +| title | tab的标题 | `String` | - | - | +| disabled | 是否禁用这个tab | `Boolean` | `false` | - | + +### Tabs Event + +| 事件名 | 说明 | 参数 | +|-----------|-----------|-----------| +| click | 某个tab点击事件 | index:点击的`tab`的索引 | +| disabled | 某个tab禁用时点击事件 | index:点击的`tab`的索引 | + diff --git a/docs/examples-docs/zh-CN/tabbar.md b/docs/markdown/zh-CN/tabbar.md similarity index 76% rename from docs/examples-docs/zh-CN/tabbar.md rename to docs/markdown/zh-CN/tabbar.md index 0a680de4064..e32c9779edc 100644 --- a/docs/examples-docs/zh-CN/tabbar.md +++ b/docs/markdown/zh-CN/tabbar.md @@ -1,32 +1,5 @@ ## Tabbar 标签栏 - - - - ### 使用指南 ``` javascript import { Tabbar, TabbarItem } from 'vant'; @@ -39,7 +12,7 @@ Vue.component(TabbarItem.name, TabbarItem); #### 基础用法 -:::demo 基础用法 + ```html 标签 @@ -58,17 +31,17 @@ export default { } } ``` -::: + #### 自定义图标 通过 icon slot 自定义图标 -:::demo 自定义图标 + ```html - + 自定义 - + 标签 标签 @@ -79,7 +52,7 @@ export default { export default { data() { return { - active2: 0, + active: 0, icon: { normal: '//img.yzcdn.cn/1.png', active: '//img.yzcdn.cn/2.png' @@ -88,7 +61,7 @@ export default { } } ``` -::: + ### Tabbar API diff --git a/docs/examples-docs/zh-CN/tag.md b/docs/markdown/zh-CN/tag.md similarity index 84% rename from docs/examples-docs/zh-CN/tag.md rename to docs/markdown/zh-CN/tag.md index 11c3479e583..7aa9b06b2ca 100644 --- a/docs/examples-docs/zh-CN/tag.md +++ b/docs/markdown/zh-CN/tag.md @@ -1,17 +1,3 @@ - - ## Tag 标记 ### 使用指南 @@ -25,38 +11,33 @@ Vue.component(Tag.name, Tag); #### 基础用法 通过 type 属性控制 Tag 颜色,默认为灰色 -:::demo 基础用法 + ```html 标签 标签 标签 标签 ``` -::: #### 空心样式 设置`plain`属性设置为空心样式 -:::demo 空心样式 ```html 标签 标签 标签 标签 ``` -::: #### 标记样式 通过`mark`设置为标记样式 -:::demo 标记样式 ```html 标签 标签 标签 标签 ``` -::: ### API diff --git a/docs/examples-docs/zh-CN/theme.md b/docs/markdown/zh-CN/theme.md similarity index 100% rename from docs/examples-docs/zh-CN/theme.md rename to docs/markdown/zh-CN/theme.md diff --git a/docs/markdown/zh-CN/toast.md b/docs/markdown/zh-CN/toast.md new file mode 100644 index 00000000000..4ec09d493cc --- /dev/null +++ b/docs/markdown/zh-CN/toast.md @@ -0,0 +1,74 @@ +## Toast 轻提示 + +### 使用指南 + +```javascript +import { Toast } from 'vant'; +``` + +### 代码演示 + +#### 文字提示 + +```javascript +Toast('我是提示文案,建议不超过十五字~'); +``` + + +#### 加载提示 + +```javascript +Toast.loading({ mask: true }); +``` + + +#### 成功/失败提示 + +```javascript +Toast.success('成功文案'); +Toast.fail('失败文案'); +``` + + +#### 高级用法 + +```javascript +const toast = Toast.loading({ + duration: 0, // 持续展示 toast + forbidClick: true, // 禁用背景点击 + message: '倒计时 3 秒' +}); + +let second = 3; +const timer = setInterval(() => { + second--; + if (second) { + toast.message = `倒计时 ${second} 秒`; + } else { + clearInterval(timer); + Toast.clear(); + } +}, 1000); +``` + + +### 方法 + +| 方法名 | 参数 | 返回值 | 介绍 | +|-----------|-----------|-----------|-------------| +| Toast | `options | message` | toast 实例 | 展示提示 | +| Toast.loading | `options | message` | toast 实例 | 展示加载提示 | +| Toast.success | `options | message` | toast 实例 | 展示成功提示 | +| Toast.fail | `options | message` | toast 实例 | 展示失败提示 | +| Toast.clear | - | `void` | 关闭提示 | + +### Options + +| 参数 | 说明 | 类型 | 默认值 | 可选值 | +|-----------|-----------|-----------|-------------|-------------| +| type | 提示类型 | `String` | `text` | `loading` `success` `fail` `html` | +| message | 内容 | `String` | `''` | - | +| position | 位置 | `String` | `middle` | `top` `bottom` | +| mask | 是否显示背景蒙层 | `Boolean` | `false` | - | +| forbidClick | 禁止背景点击 | `Boolean` | `false` | - | +| duration | 时长(ms) | `Number` | `3000` | 值为 0 时,toast 不会消失 | diff --git a/docs/examples-docs/zh-CN/tree-select.md b/docs/markdown/zh-CN/tree-select.md similarity index 55% rename from docs/examples-docs/zh-CN/tree-select.md rename to docs/markdown/zh-CN/tree-select.md index 3fe95add778..e74806120f5 100644 --- a/docs/examples-docs/zh-CN/tree-select.md +++ b/docs/markdown/zh-CN/tree-select.md @@ -1,79 +1,3 @@ - - ## TreeSelect 分类选择 ### 使用指南 @@ -87,7 +11,7 @@ Vue.component(TreeSelect.name, TreeSelect); #### 基础用法 -:::demo 基础用法 + ```html +/> ``` ```javascript @@ -114,13 +38,11 @@ export default { this.mainActiveIndex = index; }, onItemClick(data) { - console.log(data); this.activeId = data.id; } } } ``` -::: ### API @@ -128,9 +50,9 @@ export default { | 参数 | 说明 | 类型 | 默认值 | 必须 | |-----------|-----------|-----------|-------------|-------------| -| items | 分类显示所需的数据,具体数据结构可看 数据结构 | Array | [] | - | -| mainActiveIndex | 左侧导航高亮的索引 | Number | 0 | - | -| activeId | 右侧选择项,高亮的数据id | Number | 0 | - | +| items | 分类显示所需的数据,具体数据结构可看 数据结构 | `Array` | `[]` | - | +| mainActiveIndex | 左侧导航高亮的索引 | `Number` | `0` | - | +| activeId | 右侧选择项,高亮的数据id | `Number` | `0` | - | #### 事件 | 事件名 | 说明 | 参数 | diff --git a/docs/examples-docs/zh-CN/uploader.md b/docs/markdown/zh-CN/uploader.md similarity index 74% rename from docs/examples-docs/zh-CN/uploader.md rename to docs/markdown/zh-CN/uploader.md index 6dfb415cce7..a90dd6833ff 100644 --- a/docs/examples-docs/zh-CN/uploader.md +++ b/docs/markdown/zh-CN/uploader.md @@ -1,19 +1,3 @@ - - - - ## Uploader 图片上传 ### 使用指南 @@ -27,13 +11,10 @@ Vue.component(Uploader.name, Uploader); #### 基础用法 -:::demo 基础用法 ```html -
    - - - -
    + + + ``` ```javascript @@ -43,9 +24,8 @@ export default { console.log(file) } } -}; +}; ``` -::: ### API diff --git a/docs/examples-docs/zh-CN/waterfall.md b/docs/markdown/zh-CN/waterfall.md similarity index 67% rename from docs/examples-docs/zh-CN/waterfall.md rename to docs/markdown/zh-CN/waterfall.md index 46aa7ec15ab..ab48739e71f 100644 --- a/docs/examples-docs/zh-CN/waterfall.md +++ b/docs/markdown/zh-CN/waterfall.md @@ -28,65 +28,12 @@ export default { ### 代码演示 - - - - #### 基础用法 使用 `v-waterfall-lower` 监听滚动到达底部,并执行相应函数。若是函数执行中需要异步加载数据,可以将 `waterfall-disabled` 指定的值置为 true,禁止 `v-waterfall-lower` 监听滚动事件 注意:`waterfall-disabled` 传入的是 vue 对象中表示是否禁止瀑布流触发 key 值,类型是字符串 -:::demo 基础用法 + ```html -

    当即将滚动到元素底部时,会自动加载更多

      - + - +
      - - diff --git a/docs/src/doc.config.js b/docs/src/doc.config.js index 6232a9ccea4..f32d349d521 100644 --- a/docs/src/doc.config.js +++ b/docs/src/doc.config.js @@ -305,6 +305,17 @@ module.exports = { path: '/changelog', title: 'Changelog', noExample: true + }, + { + path: '/theme', + title: 'Theme (In translation)', + noExample: true + }, + { + path: '/demo', + title: 'Demo pages (In translation)', + noDocument: true, + noExample: true } ] } @@ -491,35 +502,35 @@ module.exports = { list: [ { path: '/address-edit', - title: 'AddressEdit' + title: 'AddressEdit (In translation)' }, { path: '/address-list', - title: 'AddressList' + title: 'AddressList (In translation)' }, { path: '/area', - title: 'Area' + title: 'Area (In translation)' }, { path: '/contact', - title: 'Contact' + title: 'Contact (In translation)' }, { path: '/coupon', - title: 'Coupon' + title: 'Coupon (In translation)' }, { path: '/goods-action', - title: 'GoodsAction' + title: 'GoodsAction (In translation)' }, { path: '/submit-bar', - title: 'SubmitBar' + title: 'SubmitBar (In translation)' }, { path: '/sku', - title: 'Sku' + title: 'Sku (In translation)' } ] } diff --git a/docs/src/examples.js b/docs/src/examples.js index 7bf0af32039..398b8012756 100644 --- a/docs/src/examples.js +++ b/docs/src/examples.js @@ -2,14 +2,13 @@ import Vue from 'vue'; import VueRouter from 'vue-router'; import App from './WapApp'; import routes from './router.config'; -import { setLang } from './utils/lang'; import Vant, { Lazyload } from 'packages'; -import ZanDoc from 'zan-doc'; +import VantDoc from 'vant-doc'; import 'packages/vant-css/src/index.css'; -import 'zan-doc/src/helper/touch-simulator'; +import 'vant-doc/src/helper/touch-simulator'; Vue.use(Vant); -Vue.use(ZanDoc); +Vue.use(VantDoc); Vue.use(Lazyload, { lazyComponent: true }); @@ -22,14 +21,6 @@ const router = new VueRouter({ routes: routesConfig }); -router.afterEach((route) => { - const container = document.querySelector('.examples-container'); - if (container) { - document.querySelector('.examples-container').scrollTop = 0; - } - setLang(route.meta.lang); -}); - window.vueRouter = router; if (process.env.NODE_ENV !== 'production') { diff --git a/docs/src/index.js b/docs/src/index.js index 740e1866347..7d37b518738 100644 --- a/docs/src/index.js +++ b/docs/src/index.js @@ -2,11 +2,11 @@ import Vue from 'vue'; import VueRouter from 'vue-router'; import App from './DocsApp'; import routes from './router.config'; -import ZanDoc from 'zan-doc'; +import VantDoc from 'vant-doc'; import isMobile from './utils/is-mobile'; Vue.use(VueRouter); -Vue.use(ZanDoc); +Vue.use(VantDoc); const routesConfig = routes(); diff --git a/docs/src/router.config.js b/docs/src/router.config.js index 9f681de189e..c9b409fe64b 100644 --- a/docs/src/router.config.js +++ b/docs/src/router.config.js @@ -1,18 +1,15 @@ import docConfig from './doc.config'; -import { getLang } from './utils/lang'; import DemoList from './components/demo-list'; -import componentDocs from '../examples-dist/entry-docs'; -import componentDemos from '../examples-dist/entry-demos'; -import Demo from './components/demo'; +import componentDocs from '../markdown'; +import componentDemos from '../demos'; +import { Demos } from 'vant-doc'; +import Vue from 'vue'; import './utils/iframe-router'; const registerRoute = (isExample) => { const route = [{ - path: '/', - redirect: to => `/${getLang()}/` - }, { path: '*', - redirect: to => `/${getLang()}/` + redirect: to => `/${Vue.prototype.$vantLang}/` }]; Object.keys(docConfig).forEach((lang, index) => { @@ -53,9 +50,9 @@ const registerRoute = (isExample) => { let component; if (path === '/demo') { - component = Demo; + component = Demos; } else { - component = isExample ? componentDemos[name] : componentDocs[name]; + component = isExample ? componentDemos[path.replace('/', '')] : componentDocs[name]; } route.push({ diff --git a/docs/src/utils/iframe-router.js b/docs/src/utils/iframe-router.js index f23769b7306..458045e2e4e 100644 --- a/docs/src/utils/iframe-router.js +++ b/docs/src/utils/iframe-router.js @@ -13,19 +13,20 @@ window.syncPath = function(dir) { const iframe = document.querySelector('iframe'); if (!isInIframe && !isMobile && iframe) { + const pathParts = currentDir.split('/'); + let lang = pathParts[0]; + if (currentDir[0] === '/') { + lang = pathParts[1]; + } + setLang(lang); + iframeReady(iframe, () => { - iframe.contentWindow.changePath(currentDir); + iframe.contentWindow.changePath(lang, currentDir); }); } }; -window.changePath = function(path = '') { - const pathParts = path.split('/'); - let lang = pathParts[0]; - if (path[0] === '/') { - lang = pathParts[1]; - } - +window.changePath = function(lang, path = '') { setLang(lang); window.vueRouter.replace(path); }; diff --git a/docs/src/utils/lang.js b/docs/src/utils/lang.js index 1a291fd84eb..0f117b40b41 100644 --- a/docs/src/utils/lang.js +++ b/docs/src/utils/lang.js @@ -1,16 +1,20 @@ +import Locale from '../../../packages/locale'; +import zhCN from '../../../packages/locale/lang/zh-CN'; +import enUS from '../../../packages/locale/lang/en-US'; + +const langMap = { + 'en-US': enUS, + 'zh-CN': zhCN +}; + const userLang = window.localStorage.getItem('VANT_LANGUAGE') || window.navigator.language || 'en-US'; let defaultLang = 'en-US'; if (userLang.indexOf('zh-') !== -1) { defaultLang = 'zh-CN'; } - -let currentLang = defaultLang; - -export function getLang() { - return currentLang; -} +setLang(defaultLang); export function setLang(lang) { window.localStorage.setItem('VANT_LANGUAGE', lang); - currentLang = lang; + Locale.use(lang, langMap[lang]); } diff --git a/package.json b/package.json index 994ed77e96f..6bf9b3a5fc5 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,6 @@ "highlight.js": "^9.12.0", "html-webpack-plugin": "^2.29.0", "isparta-loader": "^2.0.0", - "json-templater": "^1.0.4", "karma": "^1.7.1", "karma-chrome-launcher": "^2.2.0", "karma-coverage": "^1.1.1", @@ -90,7 +89,7 @@ "karma-sinon-chai": "^1.3.2", "karma-sourcemap-loader": "^0.3.7", "karma-spec-reporter": "^0.0.31", - "karma-webpack": "^2.0.4", + "karma-webpack": "^2.0.6", "markdown-it": "^8.4.0", "markdown-it-container": "^2.0.0", "mocha": "^3.4.2", @@ -107,6 +106,7 @@ "style-loader": "^0.19.0", "uppercamelcase": "^3.0.0", "url-loader": "^0.6.2", + "vant-doc": "0.3.16", "vue": "^2.5.3", "vue-loader": "^13.5.0", "vue-markdown-loader": "^2.2.3", @@ -115,9 +115,8 @@ "vue-style-loader": "^3.0.0", "vue-template-compiler": "^2.5.3", "webpack": "^3.8.1", - "webpack-bundle-analyzer": "^2.9.0", + "webpack-bundle-analyzer": "^2.9.1", "webpack-dev-server": "^2.9.4", - "webpack-merge": "^4.1.1", - "zan-doc": "0.3.11" + "webpack-merge": "^4.1.1" } } diff --git a/packages/address-edit/Detail.vue b/packages/address-edit/Detail.vue index c025f4ffe15..5f9bbb4cd43 100644 --- a/packages/address-edit/Detail.vue +++ b/packages/address-edit/Detail.vue @@ -1,8 +1,8 @@