From 6f2b4c99dade20e341b7f2fc2511de456e809ace Mon Sep 17 00:00:00 2001 From: neverland Date: Mon, 11 Dec 2017 20:41:19 +0800 Subject: [PATCH] [Improvement] Support Vue.use to register a component (#401) --- README.md | 2 +- build/bin/build-entry.js | 4 +- docs/demos/common.js | 3 +- docs/demos/views/layout.vue | 7 +++- docs/markdown/en-US/actionsheet.md | 2 +- docs/markdown/en-US/address-edit.md | 2 +- docs/markdown/en-US/address-list.md | 2 +- docs/markdown/en-US/area.md | 2 +- docs/markdown/en-US/badge.md | 2 +- docs/markdown/en-US/button.md | 2 +- docs/markdown/en-US/card.md | 2 +- docs/markdown/en-US/cell-swipe.md | 2 +- docs/markdown/en-US/cell.md | 4 +- docs/markdown/en-US/checkbox.md | 4 +- docs/markdown/en-US/contact.md | 6 +-- docs/markdown/en-US/coupon.md | 4 +- docs/markdown/en-US/datetime-picker.md | 2 +- docs/markdown/en-US/field.md | 2 +- docs/markdown/en-US/goods-action.md | 6 +-- docs/markdown/en-US/icon.md | 2 +- docs/markdown/en-US/layout.md | 4 +- docs/markdown/en-US/lazyload.md | 29 --------------- docs/markdown/en-US/loading.md | 2 +- docs/markdown/en-US/nav-bar.md | 2 +- docs/markdown/en-US/notice-bar.md | 2 +- docs/markdown/en-US/number-keyboard.md | 2 +- docs/markdown/en-US/pagination.md | 2 +- docs/markdown/en-US/panel.md | 2 +- docs/markdown/en-US/password-input.md | 24 +----------- docs/markdown/en-US/picker.md | 2 +- docs/markdown/en-US/popup.md | 2 +- docs/markdown/en-US/progress.md | 2 +- docs/markdown/en-US/pull-refresh.md | 2 +- docs/markdown/en-US/radio.md | 2 +- docs/markdown/en-US/search.md | 2 +- docs/markdown/en-US/sku.md | 2 +- docs/markdown/en-US/stepper.md | 2 +- docs/markdown/en-US/steps.md | 4 +- docs/markdown/en-US/submit-bar.md | 2 +- docs/markdown/en-US/swipe.md | 4 +- docs/markdown/en-US/switch-cell.md | 2 +- docs/markdown/en-US/switch.md | 2 +- docs/markdown/en-US/tab.md | 4 +- docs/markdown/en-US/tabbar.md | 4 +- docs/markdown/en-US/tag.md | 2 +- docs/markdown/en-US/tree-select.md | 4 +- docs/markdown/en-US/uploader.md | 2 +- docs/markdown/zh-CN/actionsheet.md | 2 +- docs/markdown/zh-CN/address-edit.md | 2 +- docs/markdown/zh-CN/address-list.md | 2 +- docs/markdown/zh-CN/area.md | 2 +- docs/markdown/zh-CN/badge.md | 2 +- docs/markdown/zh-CN/button.md | 2 +- docs/markdown/zh-CN/card.md | 2 +- docs/markdown/zh-CN/cell-swipe.md | 2 +- docs/markdown/zh-CN/cell.md | 4 +- docs/markdown/zh-CN/checkbox.md | 4 +- docs/markdown/zh-CN/contact.md | 6 +-- docs/markdown/zh-CN/coupon.md | 4 +- docs/markdown/zh-CN/datetime-picker.md | 2 +- docs/markdown/zh-CN/field.md | 2 +- docs/markdown/zh-CN/goods-action.md | 6 +-- docs/markdown/zh-CN/icon.md | 2 +- docs/markdown/zh-CN/layout.md | 4 +- docs/markdown/zh-CN/loading.md | 2 +- docs/markdown/zh-CN/nav-bar.md | 2 +- docs/markdown/zh-CN/notice-bar.md | 2 +- docs/markdown/zh-CN/number-keyboard.md | 2 +- docs/markdown/zh-CN/pagination.md | 2 +- docs/markdown/zh-CN/panel.md | 2 +- docs/markdown/zh-CN/password-input.md | 4 +- docs/markdown/zh-CN/picker.md | 2 +- docs/markdown/zh-CN/popup.md | 2 +- docs/markdown/zh-CN/progress.md | 2 +- docs/markdown/zh-CN/pull-refresh.md | 2 +- docs/markdown/zh-CN/radio.md | 2 +- docs/markdown/zh-CN/search.md | 2 +- docs/markdown/zh-CN/sku.md | 2 +- docs/markdown/zh-CN/stepper.md | 2 +- docs/markdown/zh-CN/steps.md | 4 +- docs/markdown/zh-CN/submit-bar.md | 2 +- docs/markdown/zh-CN/swipe.md | 4 +- docs/markdown/zh-CN/switch-cell.md | 2 +- docs/markdown/zh-CN/switch.md | 2 +- docs/markdown/zh-CN/tab.md | 4 +- docs/markdown/zh-CN/tabbar.md | 4 +- docs/markdown/zh-CN/tag.md | 2 +- docs/markdown/zh-CN/tree-select.md | 2 +- docs/markdown/zh-CN/uploader.md | 2 +- docs/src/DocsApp.vue | 5 --- docs/src/doc.config.js | 4 -- package.json | 8 ++-- packages/actionsheet/index.vue | 12 ++---- packages/address-edit/Detail.vue | 10 ++--- packages/address-edit/index.vue | 8 ++-- packages/address-list/index.vue | 7 ++-- packages/area/index.vue | 5 ++- packages/badge-group/index.vue | 6 ++- packages/badge/index.vue | 6 ++- packages/button/index.vue | 10 ++--- packages/card/index.vue | 6 ++- packages/cell-group/index.vue | 6 ++- packages/cell-swipe/index.vue | 5 ++- packages/cell/index.vue | 10 ++--- packages/checkbox-group/index.vue | 6 ++- packages/checkbox/index.vue | 10 ++--- packages/col/index.vue | 6 ++- packages/contact-card/index.vue | 13 ++----- packages/contact-edit/index.vue | 8 ++-- packages/contact-list/index.vue | 10 ++--- packages/coupon-cell/index.vue | 5 ++- packages/coupon-list/Item.vue | 10 ++--- packages/coupon-list/index.vue | 5 ++- packages/datetime-picker/index.vue | 5 ++- packages/dialog/dialog.vue | 8 ++-- packages/field/index.vue | 9 ++--- packages/goods-action-big-btn/index.vue | 7 ++-- packages/goods-action-mini-btn/index.vue | 10 ++--- packages/goods-action/index.vue | 6 ++- packages/icon/index.vue | 3 ++ packages/image-preview/image-preview.vue | 5 ++- packages/index.js | 4 +- packages/loading/index.vue | 6 ++- packages/locale/index.js | 20 ---------- packages/mixins/i18n.js | 17 +++++++++ packages/nav-bar/index.vue | 10 ++--- packages/notice-bar/index.vue | 10 ++--- packages/number-keyboard/index.vue | 6 ++- packages/pagination/index.vue | 8 ++-- packages/panel/index.vue | 6 ++- packages/password-input/index.vue | 6 ++- packages/picker/PickerColumn.vue | 6 ++- packages/picker/index.vue | 8 ++-- packages/popup/index.vue | 5 ++- packages/progress/index.vue | 6 ++- packages/pull-refresh/index.vue | 13 ++----- packages/radio-group/index.vue | 6 ++- packages/radio/index.vue | 10 ++--- packages/row/index.vue | 6 ++- packages/search/index.vue | 13 ++----- packages/sku/containers/SkuContainer.vue | 13 +++---- packages/step/index.vue | 8 ++-- packages/stepper/index.vue | 6 ++- packages/steps/index.vue | 10 ++--- packages/submit-bar/index.vue | 8 ++-- packages/swipe-item/index.vue | 6 ++- packages/swipe/index.vue | 6 ++- packages/switch-cell/index.vue | 5 ++- packages/switch/index.vue | 10 ++--- packages/tab/index.vue | 5 ++- packages/tabbar-item/index.vue | 10 ++--- packages/tabbar/index.vue | 6 ++- packages/tabs/index.vue | 5 ++- packages/tag/index.vue | 6 ++- packages/toast/toast.vue | 12 ++---- packages/tree-select/index.vue | 10 ++--- packages/uploader/index.vue | 6 ++- packages/utils/create.js | 19 ++++++++++ packages/utils/deep-assign.js | 11 ++---- packages/utils/index.js | 20 +++++++--- packages/utils/install.js | 6 +++ yarn.lock | 47 +++++++++++++++--------- 162 files changed, 432 insertions(+), 490 deletions(-) create mode 100644 packages/mixins/i18n.js create mode 100644 packages/utils/create.js create mode 100644 packages/utils/install.js diff --git a/README.md b/README.md index 4a60dbf40..0d5c881ad 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ Modern browsers and Android 4.0+, iOS 6+. ## Links - [Documentation](https://www.youzanyun.com/zanui/vant) -- [Change log](https://www.youzanyun.com/zanui/vant#/en-US/component/changelog) +- [Changelog](https://www.youzanyun.com/zanui/vant#/en-US/component/changelog) - [React UI Zent](https://www.youzanyun.com/zanui/zent) - [vue-cli-template-vant](https://github.com/youzan/vue-cli-template-vant) - [vant-demo](https://github.com/youzan/vant-demo) diff --git a/build/bin/build-entry.js b/build/bin/build-entry.js index 9877586a0..fb13ce451 100644 --- a/build/bin/build-entry.js +++ b/build/bin/build-entry.js @@ -27,8 +27,8 @@ const components = [ ]; const install = Vue => { - components.forEach(component => { - Vue.component(component.name, component); + components.forEach(Component => { + Vue.use(Component); }); }; diff --git a/docs/demos/common.js b/docs/demos/common.js index a31312f1f..26a723934 100644 --- a/docs/demos/common.js +++ b/docs/demos/common.js @@ -3,6 +3,7 @@ */ import Vue from 'vue'; +import i18n from 'packages/mixins/i18n'; import { Locale, Toast, Dialog } from 'packages'; import { DemoBlock, DemoSection } from 'vant-doc'; import { camelize } from 'packages/utils'; @@ -23,7 +24,7 @@ const demoBaseMixin = { window.Toast = Toast; window.Dialog = Dialog; -Vue.mixin(Locale.i18n); +Vue.mixin(i18n); Vue.mixin(demoBaseMixin); Vue.component('demo-block', DemoBlock); Vue.component('demo-section', DemoSection); diff --git a/docs/demos/views/layout.vue b/docs/demos/views/layout.vue index ad4503374..fad7f479b 100644 --- a/docs/demos/views/layout.vue +++ b/docs/demos/views/layout.vue @@ -42,9 +42,14 @@ export default {