[Improvement] Support Vue.use to register a component (#401)

This commit is contained in:
neverland
2017-12-11 20:41:19 +08:00
committed by GitHub
parent 7dbb5db256
commit 6f2b4c99da
162 changed files with 432 additions and 490 deletions

View File

@@ -4,7 +4,7 @@
``` javascript
import { Actionsheet } from 'vant';
Vue.component(Actionsheet.name, Actionsheet);
Vue.use(Actionsheet);
```
### Usage

View File

@@ -4,7 +4,7 @@
``` javascript
import { AddressEdit } from 'vant';
Vue.component(AddressEdit.name, AddressEdit);
Vue.use(AddressEdit);
```
### Usage

View File

@@ -4,7 +4,7 @@
``` javascript
import { AddressList } from 'vant';
Vue.component(AddressList.name, AddressList);
Vue.use(AddressList);
```
### Usage

View File

@@ -5,7 +5,7 @@
``` javascript
import { Area } from 'vant';
Vue.component(Area.name, Area);
Vue.use(Area);
```
### Usage

View File

@@ -4,7 +4,7 @@
``` javascript
import { Badge } from 'vant';
Vue.component(Badge.name, Badge);
Vue.use(Badge);
```
### Usage

View File

@@ -4,7 +4,7 @@
``` javascript
import { Button } from 'vant';
Vue.component(Button.name, Button);
Vue.use(Button);
```
### Usage

View File

@@ -4,7 +4,7 @@
``` javascript
import { Card } from 'vant';
Vue.component(Card.name, Card);
Vue.use(Card);
```
### Usage

View File

@@ -4,7 +4,7 @@
``` javascript
import { CellSwipe } from 'vant';
Vue.component(CellSwipe.name, CellSwipe);
Vue.use(CellSwipe);
```
### Usage

View File

@@ -4,8 +4,8 @@
``` javascript
import { Cell, CellGroup } from 'vant';
Vue.component(Cell.name, Cell);
Vue.component(CellGroup.name, CellGroup);
Vue.use(Cell);
Vue.use(CellGroup);
```
### Usage

View File

@@ -4,8 +4,8 @@
``` javascript
import { Checkbox, CheckboxGroup } from 'vant';
Vue.component(Checkbox.name, Checkbox);
Vue.component(CheckboxGroup.name, CheckboxGroup);
Vue.use(Checkbox);
Vue.use(CheckboxGroup);
```
### Usage

View File

@@ -5,9 +5,9 @@
``` javascript
import { ContactCard, ContactList, ContactEdit } from 'vant';
Vue.component(ContactCard.name, ContactCard);
Vue.component(ContactList.name, ContactList);
Vue.component(ContactEdit.name, ContactEdit);
Vue.use(ContactCard);
Vue.use(ContactList);
Vue.use(ContactEdit);
```
### Usage

View File

@@ -4,8 +4,8 @@
``` javascript
import { CouponCell, CouponList } from 'vant';
Vue.component(CouponCell.name, CouponCell);
Vue.component(CouponList.name, CouponList);
Vue.use(CouponCell);
Vue.use(CouponList);
```
### Usage

View File

@@ -4,7 +4,7 @@
``` javascript
import { DatetimePicker } from 'vant';
Vue.component(DatetimePicker.name, DatetimePicker);
Vue.use(DatetimePicker);
```
### Usage

View File

@@ -4,7 +4,7 @@
``` javascript
import { Field } from 'vant';
Vue.component(Field.name, Field);
Vue.use(Field);
```
### Usage

View File

@@ -8,9 +8,9 @@ import {
GoodsActionMiniBtn
} from 'vant';
Vue.component(GoodsAction.name, GoodsAction);
Vue.component(GoodsActionBigBtn.name, GoodsActionBigBtn);
Vue.component(GoodsActionMiniBtn.name, GoodsActionMiniBtn);
Vue.use(GoodsAction);
Vue.use(GoodsActionBigBtn);
Vue.use(GoodsActionMiniBtn);
```
### Usage

View File

@@ -4,7 +4,7 @@
``` javascript
import { Icon } from 'vant';
Vue.component(Icon.name, Icon);
Vue.use(Icon);
```
### Usage

View File

@@ -6,8 +6,8 @@ Quickly and easily create layouts with `van-row` and `van-col`
``` javascript
import { Row, Col } from 'vant';
Vue.component(Row.name, Row);
Vue.component(Col.name, Col);
Vue.use(Row);
Vue.use(Col);
```
### Usage

View File

@@ -1,32 +1,3 @@
<script>
export default {
data() {
return {
imageList: [
'https://img.yzcdn.cn/public_files/2017/09/05/3bd347e44233a868c99cf0fe560232be.jpg',
'https://img.yzcdn.cn/public_files/2017/09/05/c0dab461920687911536621b345a0bc9.jpg',
'https://img.yzcdn.cn/public_files/2017/09/05/4e3ea0898b1c2c416eec8c11c5360833.jpg',
'https://img.yzcdn.cn/public_files/2017/09/05/fd08f07665ed67d50e11b32a21ce0682.jpg'
],
backgroundImageList: [
'https://img.yzcdn.cn/public_files/2017/09/05/bac1903e863834ace25773f3554b6890.jpg',
'https://img.yzcdn.cn/public_files/2017/09/05/138c32d4384b5e4a78dc4e1ba58e6a80.jpg'
],
componentImageList: [
'https://img.yzcdn.cn/public_files/2017/09/05/100a7845756a70af2df513bdd1307d0e.jpg',
'https://img.yzcdn.cn/public_files/2017/09/05/8a4f5be8289cb3a7434fc19a3de780a2.jpg'
]
};
},
methods: {
handleComponentShow() {
console.log('component show');
}
}
}
</script>
## Lazyload
### Install

View File

@@ -4,7 +4,7 @@
``` javascript
import { Loading } from 'vant';
Vue.component(Loading.name, Loading);
Vue.use(Loading);
```
### Usage

View File

@@ -4,7 +4,7 @@
``` javascript
import { NavBar } from 'vant';
Vue.component(NavBar.name, NavBar);
Vue.use(NavBar);
```
### Usage

View File

@@ -4,7 +4,7 @@
``` javascript
import { NoticeBar } from 'vant';
Vue.component(NoticeBar.name, NoticeBar);
Vue.use(NoticeBar);
```
### Usage

View File

@@ -4,7 +4,7 @@
``` javascript
import { NumberKeyboard } from 'vant';
Vue.component(NumberKeyboard.name, NumberKeyboard);
Vue.use(NumberKeyboard);
```
### Usage

View File

@@ -4,7 +4,7 @@
``` javascript
import { Pagination } from 'vant';
Vue.component(Pagination.name, Pagination);
Vue.use(Pagination);
```
### Usage

View File

@@ -4,7 +4,7 @@
``` javascript
import { Panel } from 'vant';
Vue.component(Panel.name, Panel);
Vue.use(Panel);
```
### Usage

View File

@@ -1,23 +1,3 @@
<script>
export default {
data() {
return {
value: '',
showKeyboard: true
}
},
methods: {
onInput(key) {
this.value = (this.value + key).slice(0, 6);
},
onDelete() {
this.value = this.value.slice(0, this.value.length - 1);
}
}
}
</script>
## PasswordInput
The PasswordInput component is usually used with [NumberKeyboard](#/en-US/component/number-keyboard) Component.
@@ -25,8 +5,8 @@ The PasswordInput component is usually used with [NumberKeyboard](#/en-US/compon
``` javascript
import { PasswordInput, NumberKeyBoard } from 'vant';
Vue.component(PasswordInput.name, PasswordInput);
Vue.component(NumberKeyBoard.name, NumberKeyBoard);
Vue.use(PasswordInput);
Vue.use(NumberKeyBoard);
```
### Usage

View File

@@ -4,7 +4,7 @@
``` javascript
import { Picker } from 'vant';
Vue.component(Picker.name, Picker);
Vue.use(Picker);
```
### Usage

View File

@@ -4,7 +4,7 @@
``` javascript
import { Popup } from 'vant';
Vue.component(Popup.name, Popup);
Vue.use(Popup);
```
### Usage

View File

@@ -4,7 +4,7 @@
``` javascript
import { Progress } from 'vant';
Vue.component(Progress.name, Progress);
Vue.use(Progress);
```
### Usage

View File

@@ -4,7 +4,7 @@
``` javascript
import { PullRefresh } from 'vant';
Vue.component(PullRefresh.name, PullRefresh);
Vue.use(PullRefresh);
```
### Usage

View File

@@ -4,7 +4,7 @@
``` javascript
import { Radio } from 'vant';
Vue.component(Radio.name, Radio);
Vue.use(Radio);
```
### Usage

View File

@@ -4,7 +4,7 @@
``` javascript
import { Search } from 'vant';
Vue.component(Search.name, Search);
Vue.use(Search);
```
### Usage

View File

@@ -4,7 +4,7 @@
```javascript
import { Sku } from 'vant';
Vue.component(Sku.name, Sku);
Vue.use(Sku);
```
### Usage

View File

@@ -4,7 +4,7 @@
``` javascript
import { Stepper } from 'vant';
Vue.component(Stepper.name, Stepper);
Vue.use(Stepper);
```
### Usage

View File

@@ -4,8 +4,8 @@
``` javascript
import { Step, Steps } from 'vant';
Vue.component(Step.name, Step);
Vue.component(Steps.name, Steps);
Vue.use(Step);
Vue.use(Steps);
```
### Usage

View File

@@ -4,7 +4,7 @@
``` javascript
import { SubmitBar } from 'vant';
Vue.component(SubmitBar.name, SubmitBar);
Vue.use(SubmitBar);
```
### Usage

View File

@@ -4,8 +4,8 @@
``` javascript
import { Swipe, SwipeItem } from 'vant';
Vue.component(Swipe.name, Swipe);
Vue.component(SwipeItem.name, SwipeItem);
Vue.use(Swipe);
Vue.use(SwipeItem);
```
### Usage

View File

@@ -5,7 +5,7 @@
``` javascript
import { SwitchCell } from 'vant';
Vue.component(SwitchCell.name, SwitchCell);
Vue.use(SwitchCell);
```
### Usage

View File

@@ -4,7 +4,7 @@
``` javascript
import { Switch } from 'vant';
Vue.component(Switch.name, Switch);
Vue.use(Switch);
```
### Usage

View File

@@ -4,8 +4,8 @@
``` javascript
import { Tab, Tabs } from 'vant';
Vue.component(Tab.name, Tab);
Vue.component(Tabs.name, Tabs);
Vue.use(Tab);
Vue.use(Tabs);
```
### Usage

View File

@@ -4,8 +4,8 @@
``` javascript
import { Tabbar, TabbarItem } from 'vant';
Vue.component(Tabbar.name, Tabbar);
Vue.component(TabbarItem.name, TabbarItem);
Vue.use(Tabbar);
Vue.use(TabbarItem);
```
### Usage

View File

@@ -4,7 +4,7 @@
``` javascript
import { Tag } from 'vant';
Vue.component(Tag.name, Tag);
Vue.use(Tag);
```
### Usage

View File

@@ -4,7 +4,7 @@
``` javascript
import { TreeSelect } from 'vant';
Vue.component(TreeSelect.name, TreeSelect);
Vue.use(TreeSelect);
```
### Usage
@@ -62,7 +62,7 @@ export default {
### Data Structure
`items` should be an array contains specified tree objects.
In every tree object, `text` property defines the name, `id` stands for the unique key while the `children` contains sub-tree objects.
In every tree object, `text` property defines `id` stands for the unique key while the `children` contains sub-tree objects.
```javascript
[

View File

@@ -4,7 +4,7 @@
``` javascript
import { Uploader } from 'vant';
Vue.component(Uploader.name, Uploader);
Vue.use(Uploader);
```
### Usage

View File

@@ -4,7 +4,7 @@
``` javascript
import { Actionsheet } from 'vant';
Vue.component(Actionsheet.name, Actionsheet);
Vue.use(Actionsheet);
```
### 代码演示

View File

@@ -4,7 +4,7 @@
``` javascript
import { AddressEdit } from 'vant';
Vue.component(AddressEdit.name, AddressEdit);
Vue.use(AddressEdit);
```
### 代码演示

View File

@@ -4,7 +4,7 @@
``` javascript
import { AddressList } from 'vant';
Vue.component(AddressList.name, AddressList);
Vue.use(AddressList);
```
### 代码演示

View File

@@ -5,7 +5,7 @@
``` javascript
import { Area } from 'vant';
Vue.component(Area.name, Area);
Vue.use(Area);
```
### 代码演示

View File

@@ -4,7 +4,7 @@
``` javascript
import { Badge } from 'vant';
Vue.component(Badge.name, Badge);
Vue.use(Badge);
```
### 代码演示

View File

@@ -4,7 +4,7 @@
``` javascript
import { Button } from 'vant';
Vue.component(Button.name, Button);
Vue.use(Button);
```
### 代码演示

View File

@@ -4,7 +4,7 @@
``` javascript
import { Card } from 'vant';
Vue.component(Card.name, Card);
Vue.use(Card);
```
### 代码演示

View File

@@ -4,7 +4,7 @@
``` javascript
import { CellSwipe } from 'vant';
Vue.component(CellSwipe.name, CellSwipe);
Vue.use(CellSwipe);
```
### 代码演示

View File

@@ -4,8 +4,8 @@
``` javascript
import { Cell, CellGroup } from 'vant';
Vue.component(Cell.name, Cell);
Vue.component(CellGroup.name, CellGroup);
Vue.use(Cell);
Vue.use(CellGroup);
```
### 代码演示

View File

@@ -4,8 +4,8 @@
``` javascript
import { Checkbox, CheckboxGroup } from 'vant';
Vue.component(Checkbox.name, Checkbox);
Vue.component(CheckboxGroup.name, CheckboxGroup);
Vue.use(Checkbox);
Vue.use(CheckboxGroup);
```
### 代码演示

View File

@@ -5,9 +5,9 @@
``` javascript
import { ContactCard, ContactList, ContactEdit } from 'vant';
Vue.component(ContactCard.name, ContactCard);
Vue.component(ContactList.name, ContactList);
Vue.component(ContactEdit.name, ContactEdit);
Vue.use(ContactCard);
Vue.use(ContactList);
Vue.use(ContactEdit);
```
### 代码演示

View File

@@ -4,8 +4,8 @@
``` javascript
import { CouponCell, CouponList } from 'vant';
Vue.component(CouponCell.name, CouponCell);
Vue.component(CouponList.name, CouponList);
Vue.use(CouponCell);
Vue.use(CouponList);
```
### 代码演示

View File

@@ -4,7 +4,7 @@
``` javascript
import { DatetimePicker } from 'vant';
Vue.component(DatetimePicker.name, DatetimePicker);
Vue.use(DatetimePicker);
```
### 代码演示

View File

@@ -6,7 +6,7 @@
``` javascript
import { Field } from 'vant';
Vue.component(Field.name, Field);
Vue.use(Field);
```
### 代码演示

View File

@@ -8,9 +8,9 @@ import {
GoodsActionMiniBtn
} from 'vant';
Vue.component(GoodsAction.name, GoodsAction);
Vue.component(GoodsActionBigBtn.name, GoodsActionBigBtn);
Vue.component(GoodsActionMiniBtn.name, GoodsActionMiniBtn);
Vue.use(GoodsAction);
Vue.use(GoodsActionBigBtn);
Vue.use(GoodsActionMiniBtn);
```
### 代码演示

View File

@@ -4,7 +4,7 @@
``` javascript
import { Icon } from 'vant';
Vue.component(Icon.name, Icon);
Vue.use(Icon);
```
### 代码演示

View File

@@ -6,8 +6,8 @@
``` javascript
import { Row, Col } from 'vant';
Vue.component(Row.name, Row);
Vue.component(Col.name, Col);
Vue.use(Row);
Vue.use(Col);
```
### 代码演示

View File

@@ -4,7 +4,7 @@
``` javascript
import { Loading } from 'vant';
Vue.component(Loading.name, Loading);
Vue.use(Loading);
```
### 代码演示

View File

@@ -4,7 +4,7 @@
``` javascript
import { NavBar } from 'vant';
Vue.component(NavBar.name, NavBar);
Vue.use(NavBar);
```
### 代码演示

View File

@@ -4,7 +4,7 @@
``` javascript
import { NoticeBar } from 'vant';
Vue.component(NoticeBar.name, NoticeBar);
Vue.use(NoticeBar);
```
### 代码演示

View File

@@ -4,7 +4,7 @@
``` javascript
import { NumberKeyboard } from 'vant';
Vue.component(NumberKeyboard.name, NumberKeyboard);
Vue.use(NumberKeyboard);
```
### 代码演示

View File

@@ -5,7 +5,7 @@
``` javascript
import { Pagination } from 'vant';
Vue.component(Pagination.name, Pagination);
Vue.use(Pagination);
```
### 代码演示

View File

@@ -4,7 +4,7 @@
``` javascript
import { Panel } from 'vant';
Vue.component(Panel.name, Panel);
Vue.use(Panel);
```
### 代码演示

View File

@@ -5,8 +5,8 @@
``` javascript
import { PasswordInput, NumberKeyBoard } from 'vant';
Vue.component(PasswordInput.name, PasswordInput);
Vue.component(NumberKeyBoard.name, NumberKeyBoard);
Vue.use(PasswordInput);
Vue.use(NumberKeyBoard);
```
### 代码演示

View File

@@ -4,7 +4,7 @@
``` javascript
import { Picker } from 'vant';
Vue.component(Picker.name, Picker);
Vue.use(Picker);
```
### 代码演示

View File

@@ -4,7 +4,7 @@
``` javascript
import { Popup } from 'vant';
Vue.component(Popup.name, Popup);
Vue.use(Popup);
```
### 代码演示

View File

@@ -4,7 +4,7 @@
``` javascript
import { Progress } from 'vant';
Vue.component(Progress.name, Progress);
Vue.use(Progress);
```
### 代码演示

View File

@@ -4,7 +4,7 @@
``` javascript
import { PullRefresh } from 'vant';
Vue.component(PullRefresh.name, PullRefresh);
Vue.use(PullRefresh);
```
### 代码演示

View File

@@ -4,7 +4,7 @@
``` javascript
import { Radio } from 'vant';
Vue.component(Radio.name, Radio);
Vue.use(Radio);
```
### 代码演示

View File

@@ -4,7 +4,7 @@
``` javascript
import { Search } from 'vant';
Vue.component(Search.name, Search);
Vue.use(Search);
```
### 代码演示

View File

@@ -4,7 +4,7 @@
```javascript
import { Sku } from 'vant';
Vue.component(Sku.name, Sku);
Vue.use(Sku);
```
### 代码演示

View File

@@ -4,7 +4,7 @@
``` javascript
import { Stepper } from 'vant';
Vue.component(Stepper.name, Stepper);
Vue.use(Stepper);
```
### 代码演示

View File

@@ -4,8 +4,8 @@
``` javascript
import { Step, Steps } from 'vant';
Vue.component(Step.name, Step);
Vue.component(Steps.name, Steps);
Vue.use(Step);
Vue.use(Steps);
```
### 代码演示

View File

@@ -4,7 +4,7 @@
``` javascript
import { SubmitBar } from 'vant';
Vue.component(SubmitBar.name, SubmitBar);
Vue.use(SubmitBar);
```
### 代码演示

View File

@@ -4,8 +4,8 @@
``` javascript
import { Swipe, SwipeItem } from 'vant';
Vue.component(Swipe.name, Swipe);
Vue.component(SwipeItem.name, SwipeItem);
Vue.use(Swipe);
Vue.use(SwipeItem);
```
### 代码演示

View File

@@ -6,7 +6,7 @@
``` javascript
import { SwitchCell } from 'vant';
Vue.component(SwitchCell.name, SwitchCell);
Vue.use(SwitchCell);
```
### 代码演示

View File

@@ -4,7 +4,7 @@
``` javascript
import { Switch } from 'vant';
Vue.component(Switch.name, Switch);
Vue.use(Switch);
```
### 代码演示

View File

@@ -4,8 +4,8 @@
``` javascript
import { Tab, Tabs } from 'vant';
Vue.component(Tab.name, Tab);
Vue.component(Tabs.name, Tabs);
Vue.use(Tab);
Vue.use(Tabs);
```
### 代码演示

View File

@@ -4,8 +4,8 @@
``` javascript
import { Tabbar, TabbarItem } from 'vant';
Vue.component(Tabbar.name, Tabbar);
Vue.component(TabbarItem.name, TabbarItem);
Vue.use(Tabbar);
Vue.use(TabbarItem);
```
### 代码演示

View File

@@ -4,7 +4,7 @@
``` javascript
import { Tag } from 'vant';
Vue.component(Tag.name, Tag);
Vue.use(Tag);
```
### 代码演示

View File

@@ -4,7 +4,7 @@
``` javascript
import { TreeSelect } from 'vant';
Vue.component(TreeSelect.name, TreeSelect);
Vue.use(TreeSelect);
```
### 代码演示

View File

@@ -4,7 +4,7 @@
``` javascript
import { Uploader } from 'vant';
Vue.component(Uploader.name, Uploader);
Vue.use(Uploader);
```
### 代码演示