diff --git a/.editorconfig b/.editorconfig index 39cb692c8..e717f5eb6 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,7 +1,9 @@ +# http://editorconfig.org root = true [*] indent_style = space +indent_size = 2 end_of_line = lf charset = utf-8 trim_trailing_whitespace = true @@ -9,15 +11,3 @@ insert_final_newline = true [*.md] trim_trailing_whitespace = false - -[*.js] -indent_size = 2 - -[*.vue] -indent_size = 2 - -[*.css] -indent_size = 2 - -[Makefile] -indent_style = tab diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index cc194f37c..818daeeac 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -38,8 +38,12 @@ npm run dev # open http://localhost:8080 ``` -## Contribute from the browser with a single click +## Contribute online with a single click -You can use gitpod (A free online IDE) with a single click it will launch a ready to code workspace with dependencies pre-installed and the web server running so that you don't have to waste any time on the dev setup and start contributing straight away. +You can use Gitpod (A free online VS Code-like IDE) for contributing, With a single click it will launch a workspace and automatically: + +- clone the vant repo. +- run `npm run bootstrap`. +- run `npm run dev`. [](https://gitpod.io/#https://github.com/youzan/vant) diff --git a/.ls-lint.yml b/.ls-lint.yml new file mode 100644 index 000000000..e68cab8bf --- /dev/null +++ b/.ls-lint.yml @@ -0,0 +1,14 @@ +ls: + src/**: + .js: kebab-case | PascalCase + .ts: kebab-case | PascalCase + .tsx: kebab-case | PascalCase + .vue: kebab-case | PascalCase + .less: kebab-case + .spec.js: kebab-case + + types: + .d.ts: kebab-case + +ignore: + - src/locale/lang diff --git a/README.md b/README.md index 2f9ab08a5..e68ca30a5 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,13 @@
🔥 文档网站 + + 💡 国内镜像文档 + + 🇨🇳 中文版介绍 + 🚀 小程序版
@@ -24,14 +29,14 @@ ## Features -* 60+ Reusable components -* 90% Unit test coverage -* Extensive documentation and demos -* Support [babel-plugin-import](https://github.com/ant-design/babel-plugin-import) -* Support Custom Theme -* Support i18n -* Support TS -* Support SSR +- 60+ Reusable components +- 90% Unit test coverage +- Extensive documentation and demos +- Support [babel-plugin-import](https://github.com/ant-design/babel-plugin-import) +- Support Custom Theme +- Support i18n +- Support TS +- Support SSR ## Install @@ -66,17 +71,17 @@ Modern browsers and Android 4.0+, iOS 8.0+. ## Ecosystem | Project | Description | -|-----|------| +| --- | --- | | [vant-demo](https://github.com/youzan/vant-demo) | Official vant demo collection | -| [vant-weapp](https://github.com/youzan/vant-weapp) | WeChat MiniProgram UI | +| [vant-weapp](https://github.com/youzan/vant-weapp) | WeChat MiniProgram UI | | [vant-cli](https://github.com/youzan/vant/tree/dev/packages/vant-cli) | Scaffold for UI library | | [vant-icons](https://github.com/youzan/vant/tree/dev/packages/vant-icons) | Vant icons | | [vant-touch-emulator](https://github.com/youzan/vant/tree/dev/packages/vant-touch-emulator) | Using vant in desktop browsers | ## Links -* [Documentation](https://youzan.github.io/vant) -* [Changelog](https://youzan.github.io/vant#/en-US/changelog) +- [Documentation](https://youzan.github.io/vant) +- [Changelog](https://youzan.github.io/vant#/en-US/changelog) ## Preview diff --git a/README.zh-CN.md b/README.zh-CN.md index e0a8e121e..8b4179d5f 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -14,6 +14,10 @@🔥 文档网站 + + 💡 国内镜像文档 + + 🚀 小程序版
@@ -21,14 +25,14 @@ ## 特性 -* 60+ 高质量组件 -* 90% 单元测试覆盖率 -* 完善的中英文文档和示例 -* 支持按需引入 -* 支持主题定制 -* 支持国际化 -* 支持 TS -* 支持 SSR +- 60+ 高质量组件 +- 90% 单元测试覆盖率 +- 完善的中英文文档和示例 +- 支持按需引入 +- 支持主题定制 +- 支持国际化 +- 支持 TS +- 支持 SSR ## 安装 @@ -79,7 +83,7 @@ vant 也支持按需引入、CDN 引入等方式,详细说明见 [快速上手 ## 生态 | 项目 | 描述 | -|-----|------| +| --- | --- | | [vant-demo](https://github.com/youzan/vant-demo) | Vant 官方示例合集 | | [vant-weapp](https://github.com/youzan/vant-weapp) | 微信小程序组件库 | | [vant-cli](https://github.com/youzan/vant/tree/dev/packages/vant-cli) | 开箱即用的组件库搭建工具 | @@ -88,9 +92,9 @@ vant 也支持按需引入、CDN 引入等方式,详细说明见 [快速上手 ## 链接 -* [详细文档](https://youzan.github.io/vant) -* [更新日志](https://youzan.github.io/vant#/zh-CN/changelog) -* [码云镜像](https://gitee.com/organizations/vant-contrib) +- [详细文档](https://youzan.github.io/vant) +- [更新日志](https://youzan.github.io/vant#/zh-CN/changelog) +- [码云镜像](https://gitee.com/organizations/vant-contrib) ## 手机预览 diff --git a/docs/markdown/changelog.en-US.md b/docs/markdown/changelog.en-US.md index 3198209f9..b51645c41 100644 --- a/docs/markdown/changelog.en-US.md +++ b/docs/markdown/changelog.en-US.md @@ -1,5 +1,205 @@ # Changelog +### Intro + +Vant follows [Semantic Versioning 2.0.0](https://semver.org/lang/zh-CN/). + +**Release Schedule** + +- Patch version:released weekly, including features and bug fixes. +- Minor version:released every one to two months, including backwards compatible features. +- Major version:including breaking changes and new features. + +### [v2.6.2](https://github.com/youzan/vant/compare/v2.6.1...v2.6.2) + +`2020-04-18` + +**Feature** + +- Empty: support offline scenario [#6055](https://github.com/youzan/vant/issues/6055) +- NoticeBar: add replay event [#6079](https://github.com/youzan/vant/issues/6079) +- Overlay: add lock-scroll prop [#6082](https://github.com/youzan/vant/issues/6082) +- Uploader: add lazy-load prop [#6083](https://github.com/youzan/vant/issues/6083) + +**Bug Fixes** + +- Checkbox: get changed value in click event [#6066](https://github.com/youzan/vant/issues/6066) +- Picker: setColumnValues failed in cascade mode [#6080](https://github.com/youzan/vant/issues/6080) +- Slider: incorrect bar-height when vertical [#6065](https://github.com/youzan/vant/issues/6065) +- Swipe: incorrect width after resize if hidden [#6084](https://github.com/youzan/vant/issues/6084) + +### [v2.6.1](https://github.com/youzan/vant/compare/v2.6.0...v2.6.1) + +`2020-04-14` + +**Feature** + +- AddressEdit: add area-placeholder prop [#6023](https://github.com/youzan/vant/issues/6023) +- ImagePreview: support local registration [#6031](https://github.com/youzan/vant/issues/6031) + +**Bug Fixes** + +- sortChildren broke SSR [#6046](https://github.com/youzan/vant/issues/6046) +- Calendar: default-date should be today, close #6025 [#6025](https://github.com/youzan/vant/issues/6025) [#6028](https://github.com/youzan/vant/issues/6028) + +### [v2.6.0](https://github.com/youzan/vant/compare/v2.5.9...v2.6.0) + +`2020-04-09` + +**Feature** + +- add ShareSheet component [#6019](https://github.com/youzan/vant/issues/6019) +- add Empty component [#6010](https://github.com/youzan/vant/issues/6010) + +**Feature** + +- Form: add show-error prop [#5941](https://github.com/youzan/vant/issues/5941) +- Tabbar: add placeholder prop [#5979](https://github.com/youzan/vant/issues/5979) +- Sku: enable safe-area-inset-bottom by default [#5960](https://github.com/youzan/vant/issues/5960) +- Tabbar: enable safe-area-inset-bottom by default when fixed [#5968](https://github.com/youzan/vant/issues/5968) +- SubmitBar: enable safe-area-inset-bottom by default [#5956](https://github.com/youzan/vant/issues/5956) +- GoodsAction: enable safe-area-inset-bottom by default [#5955](https://github.com/youzan/vant/issues/5955) +- Swipe: allow swipe multiple item at once [#5953](https://github.com/youzan/vant/issues/5953) +- Calendar: auto selected to max range [#5992](https://github.com/youzan/vant/issues/5992) + +**Improvement** + +- NavBar: improve active feedback [#5949](https://github.com/youzan/vant/issues/5949) +- Popup: improve leave animation timing function [#5954](https://github.com/youzan/vant/issues/5954) +- Picker: improve scroll speed [#5951](https://github.com/youzan/vant/issues/5951) +- Swipe: improve swipe threshold [#6003](https://github.com/youzan/vant/issues/6003) +- TreeSelect: update nav background color [#5991](https://github.com/youzan/vant/issues/5991) + +**Bug Fixes** + +- Button: icon-prefix prop not work [#5947](https://github.com/youzan/vant/issues/5947) +- Calendar: rendering error when activated [#5978](https://github.com/youzan/vant/issues/5978) +- Form: incorrect validation order when add field dynamically [b8dea3](https://github.com/youzan/vant/commit/b8dea3c13b7dbf6533169653c493a3156c07f1d4) +- NavBar: icon align center [#5948](https://github.com/youzan/vant/issues/5948) +- Stepper: readonly not work in lagacy mobile safari [#5976](https://github.com/youzan/vant/issues/5976) + +### [v2.5.9](https://github.com/youzan/vant/compare/v2.5.8...v2.5.9) + +`2020-03-31` + +**Feature** + +- AddressEdit: add click-area event [#5939](https://github.com/youzan/vant/issues/5939) +- NavBar: add placeholder prop [#5938](https://github.com/youzan/vant/issues/5938) +- Steps: add click-step event [#5937](https://github.com/youzan/vant/issues/5937) + +**Bug Fixes** + +- NumberKeyboard: show-delete-key prop not work [#5935](https://github.com/youzan/vant/issues/5935) +- Toast: incorrect height in legacy devices [#5931](https://github.com/youzan/vant/issues/5931) +- Sticky: Fixed error when accessing the window during SSR [#5958](https://github.com/youzan/vant/issues/5958) + +### [v2.5.8](https://github.com/youzan/vant/compare/v2.5.7...v2.5.8) + +`2020-03-27` + +**Feature** + +- support generate webstorm types [#5900](https://github.com/youzan/vant/issues/5900) +- Circle: improve text padding [10f32d](https://github.com/youzan/vant/commit/10f32d6619199e99ff743cb5425db1e54e495fd0) +- Form: add show-error-message prop [#5927](https://github.com/youzan/vant/issues/5927) +- ImagePreview: enable swipe lazy-render [#5879](https://github.com/youzan/vant/issues/5879) +- Sidebar: set overflow-y auto [#5921](https://github.com/youzan/vant/issues/5921) +- Swipe: add lazy-render prop [365f2b](https://github.com/youzan/vant/commit/365f2b16f7d9592f92413e206439585468a8a1c7) +- Swipe: use flex layout [f701de](https://github.com/youzan/vant/commit/f701de9e58db5f88a582e3277c97a0c9ca99eec4) + +**Bug Fixes** + +- Calendar: fix the default date of multiple selection type [#5907](https://github.com/youzan/vant/issues/5907) +- PullRefresh: track should be full of container [#5878](https://github.com/youzan/vant/issues/5878) +- Sticky: shoud rerender after visibility changed [#5888](https://github.com/youzan/vant/issues/5888) +- Swipe: incorrect offset after resize [#5922](https://github.com/youzan/vant/issues/5922) + +### [v2.5.7](https://github.com/youzan/vant/compare/v2.5.6...v2.5.7) + +`2020-03-20` + +**Bug Fixes** + +- Locale: fix incorrect japanese filename [e8c88a](https://github.com/youzan/vant/commit/e8c88a380217eb48cef8aa7dc29d378a1031120a) + +### [v2.5.6](https://github.com/youzan/vant/compare/v2.5.5...v2.5.6) + +`2020-03-20` + +**Feature** + +- Calendar: add allow-same-day prop [#5688](https://github.com/youzan/vant/issues/5688) +- GoodsAction: add badge prop, mark info prop as deprecated [0dea9e](https://github.com/youzan/vant/commit/0dea9e2cb1562decc07ef4467d085247b91924fd) +- GridItem: add badge prop, mark info prop as deprecated [db94b2](https://github.com/youzan/vant/commit/db94b20c8258ebb31bac99ea1f0c918d62de1059) +- Icon: add badge prop, mark info prop deprecated [575577](https://github.com/youzan/vant/commit/575577ed58a1e6daa36ffba7db8054556aa0d24d) +- ImagePreview: add closed event [5b279a](https://github.com/youzan/vant/commit/5b279ab0dc862c0a3257d18fe17d04ed8dd8c1dd) +- locale: add japanese language [#5853](https://github.com/youzan/vant/issues/5853) [#5854](https://github.com/youzan/vant/issues/5854) +- SidebarItem: add badge prop, mark info prop as deprecated [01482f](https://github.com/youzan/vant/commit/01482f20bc2150a7e4667fac062b4f129b0ac0c1) +- Tab: add badge prop, mark info prop as deprecated [214b13](https://github.com/youzan/vant/commit/214b13b8fff411a401fe6ccfc9eb979a51df7461) +- TabbarItem: add badge prop, mark info prop as deprecated [d61cbd](https://github.com/youzan/vant/commit/d61cbdd086c9050fa467803be676a1eb14d50f16) +- TreeSelect: add badge option, mark info option as deprecated [0cc7a3](https://github.com/youzan/vant/commit/0cc7a305287f43314910f893092c09004cef5349) +- Uploader: add chooseFile method [#5818](https://github.com/youzan/vant/issues/5818) +- Uploader: add show-upload prop [66c0b3](https://github.com/youzan/vant/commit/66c0b3c1b7d101f242071cf90e5c0b2b899edbdd) +- Uploader: use before read promise resolved value [#5813](https://github.com/youzan/vant/issues/5813) + +**Bug Fixes** + +- Calendar: incorret button native-type [#5873](https://github.com/youzan/vant/issues/5873) +- Field: should not cache input slot [#5868](https://github.com/youzan/vant/issues/5868) +- ImagePreview: should not show previews image [7fcfc5](https://github.com/youzan/vant/commit/7fcfc5f3270d3507a002247c53a29da211f1ecb6) +- Picker: update cascade after setColumnIndex [#5807](https://github.com/youzan/vant/issues/5807) +- Picker: update cascade after setColumnValue [#5807](https://github.com/youzan/vant/issues/5807) +- Toast: should lock scroll when use forbidClick [df8777](https://github.com/youzan/vant/commit/df877751b3497eb6477797ee1a52933067e57676) + +### [v2.5.5](https://github.com/youzan/vant/compare/v2.5.4...v2.5.5) + +`2020-03-11` + +**Feature** + +- Calendar: add show-title prop [#5779](https://github.com/youzan/vant/issues/5779) +- Calendar: add show-subtitle prop [#5779](https://github.com/youzan/vant/issues/5779) +- Field: improve number keyboard [e89baa](https://github.com/youzan/vant/commit/e89baa12ae24dbd27466bd6ec694074ab99acf5d) +- Stepper: improve number keyboard [58e74a](https://github.com/youzan/vant/commit/58e74a9e8bfc36f69103c6a301170c5f6ada03dd) +- GoodsActionIcon: add dot prop [b983ac](https://github.com/youzan/vant/commit/b983ac08919056e1095767d1deb3f78e5274b41c) + +**Bug Fixes** + +- AddressEdit: check addressDetail only when showDetail is true [#5803](https://github.com/youzan/vant/issues/5803) +- Calendar: color not work in multiple mode [#5786](https://github.com/youzan/vant/issues/5786) +- Field: should not get formValue from button slot [#5785](https://github.com/youzan/vant/issues/5785) +- GoodsActionIcon: info not work with icon slot [#5788](https://github.com/youzan/vant/issues/5788) +- Stepper: skip form number validation [#5792](https://github.com/youzan/vant/issues/5792) +- Sticky: should not detect scroll when hidden [41e5c0](https://github.com/youzan/vant/commit/41e5c035dcf75c1f1d4c04673d3db255e439d452) + +### [v2.5.4](https://github.com/youzan/vant/compare/v2.5.3...v2.5.4) + +`2020-03-08` + +**Feature** + +- Calendar: add multiple type [#5705](https://github.com/youzan/vant/issues/5705) +- Field: input inherit line-height [#5737](https://github.com/youzan/vant/issues/5737) +- Search: add left slot [#5771](https://github.com/youzan/vant/issues/5771) +- Uploader: add upload-icon prop [b3b46c](https://github.com/youzan/vant/commit/b3b46cde45f885b746a2a633e5fc0e87e1881abe) +- Uploader: increase border-radius to 8px [c67918](https://github.com/youzan/vant/commit/c6791841f4b06e699a684da0243526147438d852) +- Uploader: update upload area style [bd4e64](https://github.com/youzan/vant/commit/bd4e64190e63eea30c342ea5255d8603a70385f9) + +**Bug Fixes** + +- Calendar: incorrect position when poppable is false [#5760](https://github.com/youzan/vant/issues/5760) +- DropdownMenu: menu ref may not exist in some cases [#5770](https://github.com/youzan/vant/issues/5770) +- Tabs: incorrect scrollspy position while inside a scroller [0993b3](https://github.com/youzan/vant/commit/0993b394b16fdbf92bdf02d39090e631bba1f471) +- Tabs: lock scroll not work when using scrollspy [#5727](https://github.com/youzan/vant/issues/5727) +- TimePicker: incorrect value when set min-minute dynamically [#5767](https://github.com/youzan/vant/issues/5767) + +**Types** + +- Form: fix missing scrollToField method [df4439](https://github.com/youzan/vant/commit/df4439e9f6759a446b522652233703601093e99d) +- ImagePreview: fix missing closeable option [d5438d](https://github.com/youzan/vant/commit/d5438dfe0dc9df22e94881b57def33207eca44e6) +- Toast: fix missing iconPrefix option [3237e5](https://github.com/youzan/vant/commit/3237e56561e1b6b80ea3431f3b8a9f30f61d4b08) + ### [v2.5.3](https://github.com/youzan/vant/compare/v2.5.2...v2.5.3) `2020-02-28` diff --git a/docs/markdown/changelog.zh-CN.md b/docs/markdown/changelog.zh-CN.md index ad5b13287..c94404eb2 100644 --- a/docs/markdown/changelog.zh-CN.md +++ b/docs/markdown/changelog.zh-CN.md @@ -10,6 +10,200 @@ Vant 遵循 [Semver](https://semver.org/lang/zh-CN/) 语义化版本规范。 - 次版本号:每隔一至二个月发布,包含新特性和较大的功能更新,向下兼容。 - 主版本号:发布时间不定,包含不兼容更新,预计下一个主版本会与 Vue 3.0 同期发布。 +### [v2.6.2](https://github.com/youzan/vant/compare/v2.6.1...v2.6.2) + +`2020-04-18` + +**Feature** + +- Empty: 支持在离线环境下使用 network 图片 [#6055](https://github.com/youzan/vant/issues/6055) +- NoticeBar: 新增 replay 事件,在每次滚动结束时触发 [#6079](https://github.com/youzan/vant/issues/6079) +- Overlay: 新增 lock-scroll 属性,用于控制是否锁定背景滚动 [#6082](https://github.com/youzan/vant/issues/6082) +- Uploader: 新增 lazy-load 属性,用于开启图片懒加载 [#6083](https://github.com/youzan/vant/issues/6083) + +**Bug Fixes** + +- Checkbox: 修复在 click 事件的回调中获取到的 value 未改变的问题 [#6066](https://github.com/youzan/vant/issues/6066) +- Picker: 修复级联模式下使用 setColumnValues 方法导致报错的问题 [#6080](https://github.com/youzan/vant/issues/6080) +- Slider: 修复在垂直模式下使用 bar-height 后样式错误的问题 [#6065](https://github.com/youzan/vant/issues/6065) +- Swipe: 修复元素隐藏且触发 resize 事件后渲染错误的问题 [#6084](https://github.com/youzan/vant/issues/6084) + +### [v2.6.1](https://github.com/youzan/vant/compare/v2.6.0...v2.6.1) + +`2020-04-14` + +**Feature** + +- AddressEdit: 新增 area-placeholder 属性 [#6023](https://github.com/youzan/vant/issues/6023) +- ImagePreview: 支持通过局部注册的方式使用 [#6031](https://github.com/youzan/vant/issues/6031) + +**Bug Fixes** + +- Calendar: 修复 default-date 默认值为 min-date 而不是今天的问题 [#6025](https://github.com/youzan/vant/issues/6025) [#6028](https://github.com/youzan/vant/issues/6028) +- 修复部分组件在 SSR 时报错 `Cannot read property 'children' of null` 的问题 [#6046](https://github.com/youzan/vant/issues/6046) + +### [v2.6.0](https://github.com/youzan/vant/compare/v2.5.9...v2.6.0) + +`2020-04-09` + +**Feature** + +- 新增 ShareSheet 分享面板组件,用于进行分享操作 [#6019](https://github.com/youzan/vant/issues/6019) +- 新增 Empty 空状态组件,作为空状态时的占位提示 [#6010](https://github.com/youzan/vant/issues/6010) + +
+
+**Feature**
+
+- Form: 新增 show-error 属性,用于控制展示错误提示 [#5941](https://github.com/youzan/vant/issues/5941)
+- Tabbar: 新增 placeholder 属性,用于在吸底时生成占位元素 [#5979](https://github.com/youzan/vant/issues/5979)
+- Sku: 默认开启底部安全区适配 [#5960](https://github.com/youzan/vant/issues/5960)
+- SubmitBar: 默认开启底部安全区适配 [#5956](https://github.com/youzan/vant/issues/5956)
+- GoodsAction: 默认开启底部安全区适配 [#5955](https://github.com/youzan/vant/issues/5955)
+- Tabbar: 固定在底部时默认开启底部安全区适配 [#5968](https://github.com/youzan/vant/issues/5968)
+- Swipe: 允许一次滚动多页轮播 [#5953](https://github.com/youzan/vant/issues/5953)
+- Calendar: 设置 max-range 后,选择超出范围时会自动选择到最大范围 [#5992](https://github.com/youzan/vant/issues/5992)
+
+**Improvement**
+
+- NavBar: 优化点击反馈效果 [#5949](https://github.com/youzan/vant/issues/5949)
+- Popup: 优化退场动画效果 [#5954](https://github.com/youzan/vant/issues/5954)
+- Picker: 优化惯性滑动速率 [#5951](https://github.com/youzan/vant/issues/5951)
+- Swipe: 优化滚动手势体验,滑动较慢时会回弹到原位置 [#6003](https://github.com/youzan/vant/issues/6003)
+- TreeSelect: 更新左侧栏背景色,增强区分度 [#5991](https://github.com/youzan/vant/issues/5991)
+
+**Bug Fixes**
+
+- Button: 修复 icon-prefix 属性不生效的问题 [#5947](https://github.com/youzan/vant/issues/5947)
+- Calendar: 修复 keep-alive 时可能出现渲染空白的问题 [#5978](https://github.com/youzan/vant/issues/5978)
+- Form: 修复动态插入 Field 时校验顺序错误的问题 [b8dea3](https://github.com/youzan/vant/commit/b8dea3c13b7dbf6533169653c493a3156c07f1d4)
+- NavBar: 修复图标在部分机型上不居中的问题 [#5948](https://github.com/youzan/vant/issues/5948)
+- Stepper: 修复 disable-input 属性在低版本 safari 上不生效的问题 [#5976](https://github.com/youzan/vant/issues/5976)
+
+### [v2.5.9](https://github.com/youzan/vant/compare/v2.5.8...v2.5.9)
+
+`2020-03-31`
+
+**Feature**
+
+- AddressEdit: 新增 click-area 事件 [#5939](https://github.com/youzan/vant/issues/5939)
+- NavBar: 新增 placeholder 属性 [#5938](https://github.com/youzan/vant/issues/5938)
+- Steps: 新增 click-step 事件 [#5937](https://github.com/youzan/vant/issues/5937)
+
+**Bug Fixes**
+
+- NumberKeyboard: 修复 show-delete-key 属性不生效的问题 [#5935](https://github.com/youzan/vant/issues/5935)
+- Toast: 修复在部分机型上高度错误的问题 [#5931](https://github.com/youzan/vant/issues/5931)
+- Sticky: 修复 SSR 时访问 window 对象导致报错的问题 [#5958](https://github.com/youzan/vant/issues/5958)
+
+### [v2.5.8](https://github.com/youzan/vant/compare/v2.5.7...v2.5.8)
+
+`2020-03-27`
+
+**Feature**
+
+- 新增 Webstorm 的 web-types.json 定义文件,提供智能提示 [#5900](https://github.com/youzan/vant/issues/5900)
+- Form: 新增 show-error-message 属性 [#5927](https://github.com/youzan/vant/issues/5927)
+- ImagePreview: 开启延迟渲染,提高渲染性能 [#5879](https://github.com/youzan/vant/issues/5879)
+- Swipe: 新增 lazy-render 属性 [365f2b](https://github.com/youzan/vant/commit/365f2b16f7d9592f92413e206439585468a8a1c7)
+
+**Improvement**
+
+- Circle: 优化文字边距 [10f32d](https://github.com/youzan/vant/commit/10f32d6619199e99ff743cb5425db1e54e495fd0)
+- Sidebar: 新增 overflow-y: auto 样式 [#5921](https://github.com/youzan/vant/issues/5921)
+- Swipe: 调整为 flex 布局 [f701de](https://github.com/youzan/vant/commit/f701de9e58db5f88a582e3277c97a0c9ca99eec4)
+
+**Bug Fixes**
+
+- Calendar: 修复 multiple 模式下 default-date 格式错误的问题 [#5907](https://github.com/youzan/vant/issues/5907)
+- PullRefresh: 修复内部元素高度未填满容器的问题 [#5878](https://github.com/youzan/vant/issues/5878)
+- Sticky: 修复切换显示状态时可能出现定位错误的问题 [#5888](https://github.com/youzan/vant/issues/5888)
+- Swipe: 修复屏幕 resize 后可能导致轮播位置错误的问题 [#5922](https://github.com/youzan/vant/issues/5922)
+
+### [v2.5.7](https://github.com/youzan/vant/compare/v2.5.6...v2.5.7)
+
+`2020-03-20`
+
+**Bug Fixes**
+
+- Locale: 修复日语配置文件命名错误的问题 [e8c88a](https://github.com/youzan/vant/commit/e8c88a380217eb48cef8aa7dc29d378a1031120a)
+
+### [v2.5.6](https://github.com/youzan/vant/compare/v2.5.5...v2.5.6)
+
+`2020-03-20`
+
+**Feature**
+
+- Calendar: 新增 allow-same-day 属性 [#5688](https://github.com/youzan/vant/issues/5688)
+- GoodsAction: 新增 badge 属性 [0dea9e](https://github.com/youzan/vant/commit/0dea9e2cb1562decc07ef4467d085247b91924fd)
+- GridItem: 新增 badge 属性 [db94b2](https://github.com/youzan/vant/commit/db94b20c8258ebb31bac99ea1f0c918d62de1059)
+- Icon: 新增 badge 属性 [575577](https://github.com/youzan/vant/commit/575577ed58a1e6daa36ffba7db8054556aa0d24d)
+- ImagePreview: 新增 closed 事件 [5b279a](https://github.com/youzan/vant/commit/5b279ab0dc862c0a3257d18fe17d04ed8dd8c1dd)
+- locale: 新增日语配置文件 [#5853](https://github.com/youzan/vant/issues/5853) [#5854](https://github.com/youzan/vant/issues/5854)
+- SidebarItem: 新增 badge 属性 [01482f](https://github.com/youzan/vant/commit/01482f20bc2150a7e4667fac062b4f129b0ac0c1)
+- Tab: 新增 badge 属性 [214b13](https://github.com/youzan/vant/commit/214b13b8fff411a401fe6ccfc9eb979a51df7461)
+- TabbarItem: 新增 badge 属性 [d61cbd](https://github.com/youzan/vant/commit/d61cbdd086c9050fa467803be676a1eb14d50f16)
+- TreeSelect: 新增 badge 选项 [0cc7a3](https://github.com/youzan/vant/commit/0cc7a305287f43314910f893092c09004cef5349)
+- Uploader: 新增 chooseFile 方法 [#5818](https://github.com/youzan/vant/issues/5818)
+- Uploader: 新增 show-upload 属性 [66c0b3](https://github.com/youzan/vant/commit/66c0b3c1b7d101f242071cf90e5c0b2b899edbdd)
+- Uploader: 支持在 before-read 中返回修改后的文件对象 [#5813](https://github.com/youzan/vant/issues/5813)
+
+**Bug Fixes**
+
+- Calendar: 修复在 Form 内使用时错误触发表单提交的问题 [#5873](https://github.com/youzan/vant/issues/5873)
+- Field: 修复通过插槽使用 Uploader 时上传图片未展示的问题 [#5868](https://github.com/youzan/vant/issues/5868)
+- ImagePreview: 修复上次调用结果未清除的问题 [7fcfc5](https://github.com/youzan/vant/commit/7fcfc5f3270d3507a002247c53a29da211f1ecb6)
+- Picker: 修复 setValues、setIndexes 等方法未触发多列联动更新的问题 [#5807](https://github.com/youzan/vant/issues/5807)
+- Toast: 修复设置 forbidClick 后未锁定滚动的问题 [df8777](https://github.com/youzan/vant/commit/df877751b3497eb6477797ee1a52933067e57676)
+
+### [v2.5.5](https://github.com/youzan/vant/compare/v2.5.4...v2.5.5)
+
+`2020-03-11`
+
+**Feature**
+
+- Calendar: 新增 show-title 属性 [#5779](https://github.com/youzan/vant/issues/5779)
+- Calendar: 新增 show-subtitle 属性 [#5779](https://github.com/youzan/vant/issues/5779)
+- Field: 优化虚拟键盘,type="number" 调起数字键盘 [e89baa](https://github.com/youzan/vant/commit/e89baa12ae24dbd27466bd6ec694074ab99acf5d)
+- Stepper: 优化虚拟键盘,调起数字键盘 [58e74a](https://github.com/youzan/vant/commit/58e74a9e8bfc36f69103c6a301170c5f6ada03dd)
+- GoodsActionIcon: 新增 dot 属性 [b983ac](https://github.com/youzan/vant/commit/b983ac08919056e1095767d1deb3f78e5274b41c)
+
+**Bug Fixes**
+
+- AddressEdit: 修复 showDetail 为 false 时仍然会校验地址的问题 [#5803](https://github.com/youzan/vant/issues/5803)
+- Calendar: 修复在 multiple 模式下 color 属性不生效的问题 [#5786](https://github.com/youzan/vant/issues/5786)
+- Field: 修复 button 插槽可能导致表单校验失败的问题 [#5785](https://github.com/youzan/vant/issues/5785)
+- GoodsActionIcon: 修复使用 icon 插槽时 info 属性不生效的问题 [#5788](https://github.com/youzan/vant/issues/5788)
+- Stepper: 修复在 Form 中使用时必须输入整数的问题 [#5792](https://github.com/youzan/vant/issues/5792)
+- Sticky: 修复 Sticky 切换显隐导致位置错误的问题 [41e5c0](https://github.com/youzan/vant/commit/41e5c035dcf75c1f1d4c04673d3db255e439d452)
+
+### [v2.5.4](https://github.com/youzan/vant/compare/v2.5.3...v2.5.4)
+
+`2020-03-08`
+
+**Feature**
+
+- Calendar: 新增 multiple 类型 [#5705](https://github.com/youzan/vant/issues/5705)
+- Field: 输入框增加 `line-height: inherit` 样式 [#5737](https://github.com/youzan/vant/issues/5737)
+- Search: 新增 left 插槽 [#5771](https://github.com/youzan/vant/issues/5771)
+- Uploader: 新增 upload-icon 属性 [b3b46c](https://github.com/youzan/vant/commit/b3b46cde45f885b746a2a633e5fc0e87e1881abe)
+- Uploader: 圆角大小由 4px 调整为 8px [c67918](https://github.com/youzan/vant/commit/c6791841f4b06e699a684da0243526147438d852)
+- Uploader: 优化上传区域样式 [bd4e64](https://github.com/youzan/vant/commit/bd4e64190e63eea30c342ea5255d8603a70385f9)
+
+**Bug Fixes**
+
+- Calendar: 修复 poppable 为 false 无法自动定位到当前日期的问题 [#5760](https://github.com/youzan/vant/issues/5760)
+- DropdownMenu: 修复个别情况下 scrollIntoView 报错的问题 [#5770](https://github.com/youzan/vant/issues/5770)
+- Tabs: 修复 scrollspy 在自定义的滚动容器中无法跳转的问题 [0993b3](https://github.com/youzan/vant/commit/0993b394b16fdbf92bdf02d39090e631bba1f471)
+- Tabs: 修复 scrollspy 开启时在 safari 上可能出现标签弹回的问题 [#5727](https://github.com/youzan/vant/issues/5727)
+- TimePicker: 修复动态设置 min-date 时可能出现选中项错误的问题 [#5767](https://github.com/youzan/vant/issues/5767)
+
+**Types**
+
+- Form: 修复缺少 scrollToField 方法类型定义的问题 [df4439](https://github.com/youzan/vant/commit/df4439e9f6759a446b522652233703601093e99d)
+- ImagePreview: 修复缺少 closeable 选项类型定义的问题 [d5438d](https://github.com/youzan/vant/commit/d5438dfe0dc9df22e94881b57def33207eca44e6)
+- Toast: 修复缺少 iconPrefix 选项类型定义的问题 [3237e5](https://github.com/youzan/vant/commit/3237e56561e1b6b80ea3431f3b8a9f30f61d4b08)
+
### [v2.5.3](https://github.com/youzan/vant/compare/v2.5.2...v2.5.3)
`2020-02-28`
diff --git a/docs/markdown/home.en-US.md b/docs/markdown/home.en-US.md
index 0fd88be4e..3e710f5e7 100644
--- a/docs/markdown/home.en-US.md
+++ b/docs/markdown/home.en-US.md
@@ -8,14 +8,14 @@
### Features
-* 60+ Reusable components
-* 90% Unit test coverage
-* Extensive documentation and demos
-* Support [babel-plugin-import](https://github.com/ant-design/babel-plugin-import)
-* Support Custom Theme
-* Support i18n
-* Support TS
-* Support SSR
+- 60+ Reusable components
+- 90% Unit test coverage
+- Extensive documentation and demos
+- Support [babel-plugin-import](https://github.com/ant-design/babel-plugin-import)
+- Support Custom Theme
+- Support i18n
+- Support TS
+- Support SSR
### Quickstart
@@ -32,17 +32,17 @@ Modern browsers and Android 4.0+, iOS 8.0+.
### Ecosystem
| Project | Description |
-|-----|------|
+| --- | --- |
| [vant-demo](https://github.com/youzan/vant-demo) | Official vant demo collection |
-| [vant-weapp](https://github.com/youzan/vant-weapp) | WeChat MiniProgram UI |
+| [vant-weapp](https://github.com/youzan/vant-weapp) | WeChat MiniProgram UI |
| [vant-cli](https://github.com/youzan/vant/tree/dev/packages/vant-cli) | Scaffold for UI library |
| [vant-icons](https://github.com/youzan/vant/tree/dev/packages/vant-icons) | Vant icons |
| [vant-touch-emulator](https://github.com/youzan/vant/tree/dev/packages/vant-touch-emulator) | Using vant in desktop browsers |
### Links
-* [Feedback](https://github.com/youzan/vant/issues)
-* [Changelog](#/en-US/changelog)
+- [Feedback](https://github.com/youzan/vant/issues)
+- [Changelog](#/en-US/changelog)
### LICENSE
diff --git a/docs/markdown/home.zh-CN.md b/docs/markdown/home.zh-CN.md
index 5b161f26c..91b56a0d9 100644
--- a/docs/markdown/home.zh-CN.md
+++ b/docs/markdown/home.zh-CN.md
@@ -8,14 +8,14 @@
### 特性
-* 60+ 高质量组件
-* 90% 单元测试覆盖率
-* 完善的中英文文档和示例
-* 支持按需引入
-* 支持主题定制
-* 支持国际化
-* 支持 TS
-* 支持 SSR
+- 60+ 高质量组件
+- 90% 单元测试覆盖率
+- 完善的中英文文档和示例
+- 支持按需引入
+- 支持主题定制
+- 支持国际化
+- 支持 TS
+- 支持 SSR
### 快速上手
@@ -48,7 +48,7 @@
### 生态
| 项目 | 描述 |
-|-----|------|
+| --- | --- |
| [vant-demo](https://github.com/youzan/vant-demo) | Vant 官方示例合集 |
| [vant-weapp](https://github.com/youzan/vant-weapp) | 微信小程序组件库 |
| [vant-cli](https://github.com/youzan/vant/tree/dev/packages/vant-cli) | 开箱即用的组件库搭建工具 |
@@ -57,9 +57,9 @@
### 链接
-* [意见反馈](https://github.com/youzan/vant/issues)
-* [更新日志](#/zh-CN/changelog)
-* [码云镜像](https://gitee.com/organizations/vant-contrib)
+- [意见反馈](https://github.com/youzan/vant/issues)
+- [更新日志](#/zh-CN/changelog)
+- [码云镜像](https://gitee.com/organizations/vant-contrib)
### 开源协议
diff --git a/docs/markdown/quickstart.en-US.md b/docs/markdown/quickstart.en-US.md
index 9c6ee6368..323bb918a 100644
--- a/docs/markdown/quickstart.en-US.md
+++ b/docs/markdown/quickstart.en-US.md
@@ -78,7 +78,7 @@ import { Button } from 'vant';
import Button from 'vant/lib/button';
import 'vant/lib/button/style';
```
-
+
### 3. Import all components
```js
@@ -97,17 +97,20 @@ The easiest way to use Vant is to include a CDN link in the html file, after whi
```html
-
+
-
+
-
+
```
@@ -149,15 +151,15 @@ Vant 中的样式默认使用`px`作为单位,如果需要使用`rem`单位,
```js
module.exports = {
plugins: {
- 'autoprefixer': {
- browsers: ['Android >= 4.0', 'iOS >= 8']
+ autoprefixer: {
+ browsers: ['Android >= 4.0', 'iOS >= 8'],
},
'postcss-pxtorem': {
rootValue: 37.5,
- propList: ['*']
- }
- }
-}
+ propList: ['*'],
+ },
+ },
+};
```
> 在配置 postcss-loader 时,应避免 ignore node_modules 目录,否则将导致 Vant 样式无法被编译
@@ -184,13 +186,16 @@ iPhone X 等机型底部存在底部指示条,指示条的操作区域与页
```html
-
+
+
### 组件实例方法
@@ -207,12 +212,36 @@ Vant 中的许多组件提供了实例方法,调用实例方法时,我们需
export default {
data() {
return {
- checked: false
+ checked: false,
};
},
// 注意:组件挂载后才能访问到 ref 对象
mounted() {
this.$refs.checkbox.toggle();
- }
-}
+ },
+};
```
+
+## 常见问题
+
+### 在 HTML 中无法正确渲染组件?
+
+在 HTML 中使用 Vant 组件时,你可能会碰到部分示例代码无法正确渲染的情况,比如下面的用法:
+
+```html
+
-### build-site
+## 关于桌面端组件
-构建文档站点,在`site`目录生成可用于生产环境的文档站点代码
-
-### release
-
-发布组件库,发布前会自动执行 build 和 changelog 命令
-
-### changelog
-
-基于 commit 记录生成更新日志
-
-### commit-lint
-
-校验 commit message 的格式是否符合规范,需要配合`husky`在提交 commit 时触发
-
-## 配置
-
-参见[配置指南](https://github.com/youzan/vant/tree/dev/packages/vant-cli/docs/config.md)。
-
-## 更新日志
-
-参见[更新日志](https://github.com/youzan/vant/tree/dev/packages/vant-cli/changelog.md)。
+目前 Vant Cli 仅支持移动端组件的预览,桌面端组件暂不支持预览(欢迎 PR)。
diff --git a/packages/vant-cli/changelog.md b/packages/vant-cli/changelog.md
index fa52d725b..2d83ac219 100644
--- a/packages/vant-cli/changelog.md
+++ b/packages/vant-cli/changelog.md
@@ -1,37 +1,87 @@
# 更新日志
+### [v2.4.0]
+
+`2020-04-02`
+
+- 升级 prettier v2
+- 升级 html-webpack-plugin v4
+
+### [v2.3.1]
+
+`2020-03-29`
+
+- 优化网站导航栏在大屏上的适配 ([#5928](https://github.com/youzan/vant/pull/5928))
+
+### [v2.3.0]
+
+`2020-03-25`
+
+- build 命令支持编译 scoped 样式 ([#5910](https://github.com/youzan/vant/pull/5910))
+- build 命令支持生成 WebStorm 组件定义文件 ([#5899](https://github.com/youzan/vant/issues/5899))
+- clean 命令现在会移除而不是清空文件夹 ([#5895](https://github.com/youzan/vant/issues/5895))
+- 升级 @vant/markdown-vetur 2.0.0
+
+### [v2.2.8]
+
+`2020-03-20`
+
+- 修复构建 changelog 可能失败的问题
+
+### [v2.2.7]
+
+`2020-03-19`
+
+- 新增 process.env.VANT_CLI_VERSION 环境变量
+
+### [v2.2.6]
+
+`2020-03-18`
+
+- 升级 commander 5
+- 修复右侧预览 iframe 链接可能错误的问题
+
+### [v2.2.5]
+
+`2020-03-08`
+
+- 升级依赖
+- 优化代码块与底部文字之间的间距
+- 修复 create-vant-cli-app 初始化时报错的问题
+
### [v2.2.4]
+
`2020-02-14`
- 修复在 windows 上构建出的样式入口文件路径错误的问题 ([#5655](https://github.com/youzan/vant/pull/5655)
-
### [v2.2.3]
+
`2020-02-13`
- 链接颜色调整为蓝色
-
### [v2.2.2]
+
`2020-02-05`
- 修复在 windows 上获取 markdown 路径错误的问题 ([#5626](https://github.com/youzan/vant/pull/5626))
-
### [v2.2.1]
+
`2020-02-04`
- 升级 babel@7.8
- 修复切换版本时跳转 undefined 的问题 ([#5620](https://github.com/youzan/vant/pull/5620))
-
### [v2.2.0]
+
`2020-01-19`
- 升级 @vant/eslint-config@2.0.0
-
### [v2.1.8]
+
`2020-01-18`
- 新增 create-vant-cli-app 初始化命令
@@ -39,15 +89,15 @@
- 优化站点导航栏颜色
- 优化站点代码块颜色
-
### [v2.1.7]
+
`2020-01-15`
-- 优化 help 命令
+- 优化 help 命令
- 优化控制台输出信息
-
### [v2.1.6]
+
`2020-01-12`
- 支持自定义 Postcss 配置
@@ -55,23 +105,23 @@
- 优化文档站点的 meta 字段
- 新增 API 文档中的版本标签样式
-
### [v2.1.5]
+
`2020-01-10`
- 修复编译时未替换 import 语句中的 CSS 后缀的问题
- 升级 husky 版本到 4.0
-
### [v2.1.4]
+
`2020-01-06`
**Bug Fixes**
- 锁死 @vue/test-utils 版本为 1.0.0-beta.29
-
### [v2.1.3]
+
`2020-01-06`
**Feature**
@@ -79,8 +129,8 @@
- 增加 cache-loader,提高构建速度
- 调整 jest setup 文件执行时机,延迟至 env 初始化后执行
-
### [v2.1.2]
+
`2020-01-05`
**Feature**
diff --git a/packages/vant-cli/docs/commands.md b/packages/vant-cli/docs/commands.md
new file mode 100644
index 000000000..d5e0bdfb3
--- /dev/null
+++ b/packages/vant-cli/docs/commands.md
@@ -0,0 +1,61 @@
+# 命令
+
+Vant Cli 中内置了一系列的命令,可以将命令添加到 npm scripts 中进行使用。
+
+```json
+// package.json
+{
+ "scripts": {
+ "dev": "vant-cli dev",
+ "test": "vant-cli test",
+ "lint": "vant-cli lint",
+ "release": "vant-cli release",
+ "build-site": "vant-cli build-site"
+ }
+}
+```
+
+也可以通过 npm 自带的 [npx](https://github.com/npm/npx) 直接执行某个命令:
+
+```bash
+npx vant-cli dev
+```
+
+### dev
+
+运行本地开发环境。
+
+运行 dev 命令时,Vant Cli 会通过 [webpack-dev-server](https://github.com/webpack/webpack-dev-server) 启动一个本地服务器,用于在开发过程中对文档和示例进行预览。
+
+### build
+
+构建组件库。
+
+运行 build 命令会在 `es` 和 `lib` 目录下生成可用于生产环境的组件代码,详见 [目录结构](https://github.com/youzan/vant/tree/dev/packages/vant-cli/docs/directory.md)。
+
+发布 npm 时,请将以下配置加入到 `package.json` 中,使 npm 包能被正确识别:
+
+```json
+// package.json
+{
+ "main": "lib/index.js",
+ "module": "es/index.js",
+ "files": ["es", "lib"]
+}
+```
+
+### build-site
+
+构建文档站点,在 `site` 目录生成可用于生产环境的文档站点代码。
+
+### release
+
+发布组件库,发布前会自动执行 build 和 changelog 命令,并通过 [release-it](https://github.com/release-it/release-it) 发布 npm 包。
+
+## changelog
+
+基于 commit 记录生成更新日志,基于 [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog) 实现。
+
+## commit-lint
+
+校验 commit message 的格式是否符合规范,需要配合 `husky` 在提交 commit 时触发。
diff --git a/packages/vant-cli/docs/directory.md b/packages/vant-cli/docs/directory.md
new file mode 100644
index 000000000..66405fe55
--- /dev/null
+++ b/packages/vant-cli/docs/directory.md
@@ -0,0 +1,81 @@
+# 目录结构
+
+## 源代码目录
+
+基于 Vant Cli 搭建的组件库的基本目录结构如下所示:
+
+```
+project
+├─ src # 组件源代码
+│ ├─ button # button 组件源代码
+│ └─ dialog # dialog 组件源代码
+│
+├─ docs # 静态文档目录
+│ ├─ home.md # 文档首页
+│ └─ changelog.md # 更新日志
+│
+├─ babel.config.js # Babel 配置文件
+├─ vant.config.js # Vant Cli 配置文件
+├─ pacakge.json
+└─ README.md
+```
+
+单个组件的目录如下:
+
+```
+button
+├─ demo # 示例目录
+│ └─ index.vue # 组件示例
+├─ index.vue # 组件源码
+└─ README.md # 组件文档
+```
+
+使用 .vue 文件编写组件时,编译后会生成对应的 JS 和 CSS 文件,且 JS 文件中会自动引入 CSS 文件。
+
+如果需要将 JS 和 CSS 解耦,实现主题定制等功能,在编写代码时就要使用独立的 JS 和 CSS 文件,如下所示:
+
+```
+button
+├─ demo # 组件示例
+│ └─ index.vue # 组件示例入口
+├─ index.js # 组件入口
+├─ index.less # 组件样式,可以为 less 或 scss
+└─ README.md # 组件文档
+```
+
+采用这种目录结构时,组件的使用者需要分别引入 JS 和 CSS 文件,也可以通过 babel-plugin-import 自动引入样式。
+
+通过引入样式源文件(less 或 scss)并修改样式变量,可以实现主题定制功能。
+
+## 构建结果目录
+
+运行 build 命令会在 `es` 和 `lib` 目录下生成可用于生产环境的组件代码,结构如下:
+
+```
+project
+├─ es # es 目录下的代码遵循 esmodule 规范
+│ ├─ button # button 组件编译后的代码目录
+│ ├─ dialog # dialog 组件编译后的代码目录
+│ └─ index.js # 引入所有组件的入口,支持 tree shaking
+│
+└─ lib # lib 目录下的代码遵循 commonjs 规范
+ ├─ button # button 组件编译后的代码目录
+ ├─ dialog # dialog 组件编译后的代码目录
+ ├─ index.js # 引入所有组件的入口
+ ├─ index.less # 所有组件未编译的样式
+ ├─ index.css # 所有组件打包后的样式,用于 CDN 引入
+ ├─ name.js # 所有组件打包后的脚本,未压缩,用于 CDN 引入
+ └─ name.min.js # 所有组件打包后的脚本,已压缩,用于 CDN 引入
+```
+
+单个组件编译后的目录如下:
+
+```
+button
+├─ index.js # 组件编译后的 JS 文件
+├─ index.css # 组件编译后的 CSS 文件
+├─ index.less # 组件编译前的 CSS 文件,可以为 less 或 scss
+└─ style # 按需引入样式的入口
+ ├─ index.js # 按需引入编译后的样式
+ └─ less.js # 按需引入未编译的样式,可用于主题定制
+```
diff --git a/packages/vant-cli/package.json b/packages/vant-cli/package.json
index c0d84a957..dd75cedc1 100644
--- a/packages/vant-cli/package.json
+++ b/packages/vant-cli/package.json
@@ -1,6 +1,6 @@
{
"name": "@vant/cli",
- "version": "2.2.4",
+ "version": "2.4.0",
"description": "",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
@@ -34,73 +34,71 @@
},
"devDependencies": {
"@types/fs-extra": "^8.1.0",
- "@types/html-webpack-plugin": "^3.2.2",
"@types/lodash": "^4.14.149",
"@types/postcss-load-config": "^2.0.1",
- "@types/sass": "^1.16.0",
- "@types/shelljs": "^0.8.6",
- "@types/webpack": "^4.41.6",
- "@types/webpack-dev-server": "^3.10.0",
+ "@types/webpack": "^4.41.10",
+ "@types/webpack-dev-server": "^3.10.1",
"@types/webpack-merge": "^4.1.5"
},
"dependencies": {
- "@babel/core": "^7.8.4",
+ "@babel/core": "^7.9.0",
"@babel/plugin-syntax-jsx": "^7.8.3",
"@babel/plugin-transform-object-assign": "^7.8.3",
- "@babel/plugin-transform-runtime": "^7.8.3",
- "@babel/preset-env": "^7.8.4",
- "@babel/preset-typescript": "^7.8.3",
+ "@babel/plugin-transform-runtime": "^7.9.0",
+ "@babel/preset-env": "^7.9.5",
+ "@babel/preset-typescript": "^7.9.0",
"@nuxt/friendly-errors-webpack-plugin": "^2.5.0",
- "@types/jest": "^25.1.3",
+ "@types/jest": "^25.2.1",
"@vant/eslint-config": "^2.0.0",
"@vant/markdown-loader": "^2.3.0",
- "@vant/markdown-vetur": "^1.1.0",
- "@vant/stylelint-config": "^1.1.0",
+ "@vant/markdown-vetur": "^2.0.1",
+ "@vant/stylelint-config": "^1.3.0",
"@vant/touch-emulator": "^1.2.0",
"@vue/babel-preset-jsx": "^1.1.2",
- "@vue/component-compiler-utils": "^3.1.1",
+ "@vue/component-compiler-utils": "^3.1.2",
"@vue/test-utils": "1.0.0-beta.29",
"address": "^1.1.2",
- "autoprefixer": "^9.7.4",
- "babel-jest": "^25.1.0",
- "babel-loader": "^8.0.6",
+ "autoprefixer": "^9.7.6",
+ "babel-jest": "^25.3.0",
+ "babel-loader": "^8.1.0",
"babel-plugin-import": "^1.13.0",
"cache-loader": "^4.1.0",
"chokidar": "^3.3.1",
"clean-css": "^4.2.3",
"codecov": "^3.6.5",
- "commander": "^4.1.1",
+ "commander": "^5.0.0",
"consola": "^2.11.3",
"conventional-changelog": "^3.1.18",
- "cross-env": "^7.0.0",
- "css-loader": "^3.4.2",
+ "cross-env": "^7.0.2",
+ "css-loader": "^3.5.2",
"eslint": "^6.8.0",
- "fast-glob": "^3.2.1",
- "gh-pages": "2.0.1",
- "html-webpack-plugin": "3.2.0",
- "husky": "^4.2.3",
- "jest": "^25.1.0",
+ "fast-glob": "^3.2.2",
+ "gh-pages": "^2.2.0",
+ "hash-sum": "^2.0.0",
+ "html-webpack-plugin": "4.2.0",
+ "husky": "^4.2.5",
+ "jest": "^25.3.0",
"jest-canvas-mock": "^2.2.0",
"jest-serializer-vue": "^2.0.2",
"less": "^3.11.1",
"less-loader": "^5.0.0",
- "lint-staged": "^10.0.7",
+ "lint-staged": "^10.1.3",
"lodash": "^4.17.15",
"ora": "^4.0.3",
"portfinder": "^1.0.25",
"postcss": "^7.0.27",
"postcss-loader": "^3.0.0",
- "release-it": "^12.6.0",
- "sass": "^1.25.0",
+ "prettier": "^2.0.4",
+ "release-it": "^13.5.2",
+ "sass": "^1.26.3",
"sass-loader": "^8.0.2",
- "shelljs": "^0.8.3",
"style-loader": "^1.1.3",
- "stylelint": "^13.2.0",
- "typescript": "^3.8.2",
+ "stylelint": "^13.3.1",
+ "typescript": "^3.8.3",
"vue-jest": "4.0.0-beta.2",
- "vue-loader": "^15.9.0",
- "vue-router": "^3.1.5",
- "webpack": "^4.41.6",
+ "vue-loader": "^15.9.1",
+ "vue-router": "^3.1.6",
+ "webpack": "^4.42.1",
"webpack-dev-server": "3.10.3",
"webpack-merge": "^4.2.2",
"webpackbar": "^4.0.0"
diff --git a/packages/vant-cli/site/common/style/highlight.less b/packages/vant-cli/site/common/style/highlight.less
index e0b25a2c8..07cf774c5 100644
--- a/packages/vant-cli/site/common/style/highlight.less
+++ b/packages/vant-cli/site/common/style/highlight.less
@@ -3,7 +3,6 @@
code {
position: relative;
display: block;
- margin-top: 20px;
overflow-x: auto;
color: @van-doc-code-color;
font-weight: 400;
@@ -16,7 +15,11 @@ code {
}
pre {
- margin: 0;
+ margin: 20px 0 0;
+
+ + p {
+ margin-top: 20px;
+ }
}
.hljs {
diff --git a/packages/vant-cli/site/desktop/App.vue b/packages/vant-cli/site/desktop/App.vue
index b633671c8..6e7cbc46f 100644
--- a/packages/vant-cli/site/desktop/App.vue
+++ b/packages/vant-cli/site/desktop/App.vue
@@ -23,7 +23,7 @@ export default {
},
data() {
- const path = location.pathname.replace('/index', '/');
+ const path = location.pathname.replace(/\/index(\.html)?/, '/');
return {
packageVersion,
diff --git a/packages/vant-cli/site/desktop/components/Header.vue b/packages/vant-cli/site/desktop/components/Header.vue
index b987ac65d..95fd21cd9 100644
--- a/packages/vant-cli/site/desktop/components/Header.vue
+++ b/packages/vant-cli/site/desktop/components/Header.vue
@@ -140,6 +140,7 @@ export default {
.van-doc-header {
width: 100%;
+ background-color: #001938;
user-select: none;
&__top {
@@ -148,7 +149,6 @@ export default {
height: @van-doc-header-top-height;
padding: 0 @van-doc-padding;
line-height: @van-doc-header-top-height;
- background-color: #001938;
&-nav {
flex: 1;
diff --git a/packages/vant-cli/site/desktop/components/index.vue b/packages/vant-cli/site/desktop/components/index.vue
index 09c069b6a..c087db09c 100644
--- a/packages/vant-cli/site/desktop/components/index.vue
+++ b/packages/vant-cli/site/desktop/components/index.vue
@@ -51,7 +51,7 @@ export default {
},
watch: {
- // eslint-disable-next-line
+ // eslint-disable-next-line object-shorthand
'$route.path'() {
this.setNav();
},
@@ -88,7 +88,7 @@ export default {
},
keyboardHandler() {
- window.addEventListener('keyup', event => {
+ window.addEventListener('keyup', (event) => {
switch (event.keyCode) {
case 37: // left
this.keyboardNav('prev');
diff --git a/packages/vant-cli/site/mobile/components/DemoNav.vue b/packages/vant-cli/site/mobile/components/DemoNav.vue
index 9cc7e9305..b5509c7e9 100644
--- a/packages/vant-cli/site/mobile/components/DemoNav.vue
+++ b/packages/vant-cli/site/mobile/components/DemoNav.vue
@@ -26,7 +26,11 @@ export default {
methods: {
onBack() {
- history.back();
+ if (history.length > 1) {
+ history.back();
+ } else {
+ this.$router.replace('/');
+ }
},
},
};
diff --git a/packages/vant-cli/src/commands/changelog.ts b/packages/vant-cli/src/commands/changelog.ts
index 5370fef87..3d5141b59 100644
--- a/packages/vant-cli/src/commands/changelog.ts
+++ b/packages/vant-cli/src/commands/changelog.ts
@@ -2,7 +2,6 @@ import { join } from 'path';
import { ROOT } from '../common/constant';
import { ora, slimPath } from '../common/logger';
import { createWriteStream, readFileSync } from 'fs-extra';
-// @ts-ignore
import conventionalChangelog from 'conventional-changelog';
const DIST_FILE = join(ROOT, './changelog.generated.md');
@@ -38,7 +37,7 @@ function transform(item: any) {
if (item.references.length) {
item.references.forEach((ref: any) => {
- if (ref.issue) {
+ if (ref.issue && item.subject) {
item.subject = item.subject.replace(` (#${ref.issue})`, '');
}
});
diff --git a/packages/vant-cli/src/commands/clean.ts b/packages/vant-cli/src/commands/clean.ts
index 080b15b54..cf71d54c0 100644
--- a/packages/vant-cli/src/commands/clean.ts
+++ b/packages/vant-cli/src/commands/clean.ts
@@ -1,11 +1,18 @@
-import { emptyDir } from 'fs-extra';
-import { ES_DIR, LIB_DIR, DIST_DIR, SITE_DIST_DIR } from '../common/constant';
+import { remove } from 'fs-extra';
+import {
+ ES_DIR,
+ LIB_DIR,
+ DIST_DIR,
+ VETUR_DIR,
+ SITE_DIST_DIR,
+} from '../common/constant';
export async function clean() {
await Promise.all([
- emptyDir(ES_DIR),
- emptyDir(LIB_DIR),
- emptyDir(DIST_DIR),
- emptyDir(SITE_DIST_DIR),
+ remove(ES_DIR),
+ remove(LIB_DIR),
+ remove(DIST_DIR),
+ remove(VETUR_DIR),
+ remove(SITE_DIST_DIR),
]);
}
diff --git a/packages/vant-cli/src/commands/lint.ts b/packages/vant-cli/src/commands/lint.ts
index 2f54a5098..ee1aacd2d 100644
--- a/packages/vant-cli/src/commands/lint.ts
+++ b/packages/vant-cli/src/commands/lint.ts
@@ -1,4 +1,3 @@
-// @ts-ignore
import execa from 'execa';
import { ora } from '../common/logger';
import { SCRIPT_EXTS } from '../common/constant';
diff --git a/packages/vant-cli/src/commands/release.ts b/packages/vant-cli/src/commands/release.ts
index e6270ace3..32c3babd9 100644
--- a/packages/vant-cli/src/commands/release.ts
+++ b/packages/vant-cli/src/commands/release.ts
@@ -1,5 +1,4 @@
/* eslint-disable no-template-curly-in-string */
-// @ts-ignore
import releaseIt from 'release-it';
import { join } from 'path';
diff --git a/packages/vant-cli/src/common/constant.ts b/packages/vant-cli/src/common/constant.ts
index 9cdc8d149..b266ec61a 100644
--- a/packages/vant-cli/src/common/constant.ts
+++ b/packages/vant-cli/src/common/constant.ts
@@ -23,6 +23,7 @@ export const ROOT = findRootDir(CWD);
export const ES_DIR = join(ROOT, 'es');
export const LIB_DIR = join(ROOT, 'lib');
export const DOCS_DIR = join(ROOT, 'docs');
+export const VETUR_DIR = join(ROOT, 'vetur');
export const SITE_DIST_DIR = join(ROOT, 'site');
export const VANT_CONFIG_FILE = join(ROOT, 'vant.config.js');
export const PACKAGE_JSON_FILE = join(ROOT, 'package.json');
diff --git a/packages/vant-cli/src/common/manager.ts b/packages/vant-cli/src/common/manager.ts
index 22ea1be29..d055f5fb1 100644
--- a/packages/vant-cli/src/common/manager.ts
+++ b/packages/vant-cli/src/common/manager.ts
@@ -1,4 +1,3 @@
-// @ts-ignore
import execa from 'execa';
import { consola } from './logger';
import { execSync } from 'child_process';
diff --git a/packages/vant-cli/src/compiler/compile-less.ts b/packages/vant-cli/src/compiler/compile-less.ts
index 1c548fc3f..3d71adb66 100644
--- a/packages/vant-cli/src/compiler/compile-less.ts
+++ b/packages/vant-cli/src/compiler/compile-less.ts
@@ -1,4 +1,3 @@
-// @ts-ignore
import { render, FileManager } from 'less';
import { readFileSync } from 'fs-extra';
diff --git a/packages/vant-cli/src/compiler/compile-sfc.ts b/packages/vant-cli/src/compiler/compile-sfc.ts
index 1cb6badbd..0a162e3c9 100644
--- a/packages/vant-cli/src/compiler/compile-sfc.ts
+++ b/packages/vant-cli/src/compiler/compile-sfc.ts
@@ -1,5 +1,6 @@
import * as compiler from 'vue-template-compiler';
import * as compileUtils from '@vue/component-compiler-utils';
+import hash from 'hash-sum';
import { parse } from 'path';
import { remove, writeFileSync, readFileSync } from 'fs-extra';
import { replaceExt } from '../common';
@@ -34,6 +35,10 @@ function injectRender(script: string, render: string) {
);
}
+function injectScopeId(script: string, scopeId: string) {
+ return script.replace(EXPORT, `${EXPORT}\n _scopeId: '${scopeId}',\n\n`);
+}
+
function injectStyle(
script: string,
styles: compileUtils.SFCBlock[],
@@ -63,10 +68,6 @@ function compileTemplate(template: string) {
return result.code;
}
-type CompileSfcOptions = {
- skipStyle?: boolean;
-};
-
export function parseSfc(filePath: string) {
const source = readFileSync(filePath, 'utf-8');
@@ -79,15 +80,16 @@ export function parseSfc(filePath: string) {
return descriptor;
}
-export async function compileSfc(
- filePath: string,
- options: CompileSfcOptions = {}
-): Promise{description}
; + } + }, + + genBottom() { + const slot = this.slots(); + + if (slot) { + return
描述文字
+
描述文字
+
描述文字
+
描述文字
+ +

Custom description
+