docs: add import when using Toast or Notify

This commit is contained in:
陈嘉涵 2020-01-18 08:25:24 +08:00
parent 78e4c153b1
commit 9bcfddc958
68 changed files with 206 additions and 149 deletions

View File

@ -19,7 +19,9 @@ Use `actions` prop to set options of action-sheet.
<van-action-sheet v-model="show" :actions="actions" @select="onSelect" /> <van-action-sheet v-model="show" :actions="actions" @select="onSelect" />
``` ```
```javascript ```js
import { Toast } from 'vant';
export default { export default {
data() { data() {
return { return {
@ -31,7 +33,6 @@ export default {
] ]
}; };
}, },
methods: { methods: {
onSelect(item) { onSelect(item) {
this.show = false; this.show = false;
@ -47,7 +48,7 @@ export default {
<van-action-sheet v-model="show" :actions="actions" /> <van-action-sheet v-model="show" :actions="actions" />
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {
@ -74,13 +75,14 @@ export default {
``` ```
```js ```js
import { Toast } from 'vant';
export default { export default {
data() { data() {
return { return {
show: false show: false
}; };
}, },
methods: { methods: {
onCancel() { onCancel() {
this.show = false; this.show = false;

View File

@ -19,7 +19,9 @@ Vue.use(ActionSheet);
<van-action-sheet v-model="show" :actions="actions" @select="onSelect" /> <van-action-sheet v-model="show" :actions="actions" @select="onSelect" />
``` ```
```javascript ```js
import { Toast } from 'vant';
export default { export default {
data() { data() {
return { return {
@ -31,7 +33,6 @@ export default {
] ]
}; };
}, },
methods: { methods: {
onSelect(item) { onSelect(item) {
// 默认情况下,点击选项时不会自动关闭菜单 // 默认情况下,点击选项时不会自动关闭菜单
@ -51,7 +52,7 @@ export default {
<van-action-sheet v-model="show" :actions="actions" /> <van-action-sheet v-model="show" :actions="actions" />
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {
@ -80,13 +81,14 @@ export default {
``` ```
```js ```js
import { Toast } from 'vant';
export default { export default {
data() { data() {
return { return {
show: false show: false
}; };
}, },
methods: { methods: {
onCancel() { onCancel() {
this.show = false; this.show = false;

View File

@ -28,7 +28,9 @@ Vue.use(AddressEdit);
/> />
``` ```
```javascript ```js
import { Toast } from 'vant';
export default { export default {
data() { data() {
return { return {
@ -36,7 +38,6 @@ export default {
searchResult: [] searchResult: []
} }
}, },
methods: { methods: {
onSave() { onSave() {
Toast('save'); Toast('save');

View File

@ -28,7 +28,9 @@ Vue.use(AddressEdit);
/> />
``` ```
```javascript ```js
import { Toast } from 'vant';
export default { export default {
data() { data() {
return { return {
@ -36,7 +38,6 @@ export default {
searchResult: [] searchResult: []
} }
}, },
methods: { methods: {
onSave() { onSave() {
Toast('save'); Toast('save');

View File

@ -25,7 +25,9 @@ Vue.use(AddressList);
/> />
``` ```
```javascript ```js
import { Toast } from 'vant';
export default { export default {
data() { data() {
return { return {
@ -54,7 +56,6 @@ export default {
] ]
} }
}, },
methods: { methods: {
onAdd() { onAdd() {
Toast('Add'); Toast('Add');

View File

@ -25,7 +25,9 @@ Vue.use(AddressList);
/> />
``` ```
```javascript ```js
import { Toast } from 'vant';
export default { export default {
data() { data() {
return { return {
@ -54,12 +56,10 @@ export default {
] ]
} }
}, },
methods: { methods: {
onAdd() { onAdd() {
Toast('新增地址'); Toast('新增地址');
}, },
onEdit(item, index) { onEdit(item, index) {
Toast('编辑地址:' + index); Toast('编辑地址:' + index);
} }

View File

@ -94,7 +94,7 @@ Each property is a simple key-value object, key is a 6-bit code of the area of w
Example of `AreaList` Example of `AreaList`
```javascript ```js
{ {
province_list: { province_list: {
110000: 'Beijing', 110000: 'Beijing',
@ -123,7 +123,7 @@ All code of China: [Area.json](https://github.com/youzan/vant/blob/dev/src/area/
An array contains selected area objects. An array contains selected area objects.
`code` - code of selected area, `name` - name of selected area `code` - code of selected area, `name` - name of selected area
```javascript ```js
[{ [{
code: '330000', code: '330000',
name: 'Zhejiang Province' name: 'Zhejiang Province'

View File

@ -6,7 +6,7 @@
### 引入 ### 引入
```javascript ```js
import Vue from 'vue'; import Vue from 'vue';
import { Area } from 'vant'; import { Area } from 'vant';
@ -94,7 +94,7 @@ Vue.use(Area);
`AreaList`具体格式如下: `AreaList`具体格式如下:
```javascript ```js
{ {
province_list: { province_list: {
110000: '北京市', 110000: '北京市',
@ -129,7 +129,7 @@ Vue.use(Area);
`code` 代表被选中的地区编码, `name` 代表被选中的地区名称 `code` 代表被选中的地区编码, `name` 代表被选中的地区名称
```javascript ```js
[ [
{ {
code: '110000', code: '110000',

View File

@ -18,7 +18,7 @@ Vue.use(CheckboxGroup);
<van-checkbox v-model="checked">Checkbox</van-checkbox> <van-checkbox v-model="checked">Checkbox</van-checkbox>
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {
@ -97,7 +97,7 @@ When Checkboxes are inside a CheckboxGroup, the checked checkboxes's name is an
</van-checkbox-group> </van-checkbox-group>
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {

View File

@ -20,7 +20,7 @@ Vue.use(CheckboxGroup);
<van-checkbox v-model="checked">复选框</van-checkbox> <van-checkbox v-model="checked">复选框</van-checkbox>
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {
@ -107,7 +107,7 @@ export default {
</van-checkbox-group> </van-checkbox-group>
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {

View File

@ -89,6 +89,8 @@ export default {
``` ```
```js ```js
import { Toast } from 'vant';
export default { export default {
methods: { methods: {
start() { start() {
@ -101,7 +103,7 @@ export default {
this.$refs.countDown.reset(); this.$refs.countDown.reset();
}, },
finish() { finish() {
this.$toast('Finished'); Toast('Finished');
} }
} }
} }

View File

@ -99,6 +99,8 @@ export default {
``` ```
```js ```js
import { Toast } from 'vant';
export default { export default {
methods: { methods: {
start() { start() {
@ -111,7 +113,7 @@ export default {
this.$refs.countDown.reset(); this.$refs.countDown.reset();
}, },
finish() { finish() {
this.$toast('倒计时结束'); Toast('倒计时结束');
} }
} }
} }

View File

@ -39,7 +39,7 @@ Vue.use(CouponList);
</van-popup> </van-popup>
``` ```
```javascript ```js
const coupon = { const coupon = {
available: 1, available: 1,
originCondition: 0, originCondition: 0,

View File

@ -39,7 +39,7 @@ Vue.use(CouponList);
</van-popup> </van-popup>
``` ```
```javascript ```js
const coupon = { const coupon = {
available: 1, available: 1,
condition: '无使用门槛\n最多优惠12元', condition: '无使用门槛\n最多优惠12元',

View File

@ -26,7 +26,7 @@ Vue.use(DatetimePicker);
/> />
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {

View File

@ -6,7 +6,7 @@
### 引入 ### 引入
```javascript ```js
import Vue from 'vue'; import Vue from 'vue';
import { DatetimePicker } from 'vant'; import { DatetimePicker } from 'vant';
@ -26,7 +26,7 @@ Vue.use(DatetimePicker);
/> />
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {

View File

@ -15,7 +15,7 @@ Vue.use(Dialog);
Used to prompt for some messages, only including one confirm button Used to prompt for some messages, only including one confirm button
```javascript ```js
Dialog.alert({ Dialog.alert({
title: 'Title', title: 'Title',
message: 'Content' message: 'Content'
@ -34,7 +34,7 @@ Dialog.alert({
Used to confirm some messages, including a confirm button and a cancel button Used to confirm some messages, including a confirm button and a cancel button
```javascript ```js
Dialog.confirm({ Dialog.confirm({
title: 'Title', title: 'Title',
message: 'Content' message: 'Content'

View File

@ -41,7 +41,7 @@ export default {
用于提示一些消息,只包含一个确认按钮 用于提示一些消息,只包含一个确认按钮
```javascript ```js
Dialog.alert({ Dialog.alert({
title: '标题', title: '标题',
message: '弹窗内容' message: '弹窗内容'
@ -60,7 +60,7 @@ Dialog.alert({
用于确认消息,包含取消和确认按钮 用于确认消息,包含取消和确认按钮
```javascript ```js
Dialog.confirm({ Dialog.confirm({
title: '标题', title: '标题',
message: '弹窗内容' message: '弹窗内容'

View File

@ -24,7 +24,9 @@ Vue.use(GoodsActionIcon);
</van-goods-action> </van-goods-action>
``` ```
```javascript ```js
import { Toast } from 'vant';
export default { export default {
methods: { methods: {
onClickIcon() { onClickIcon() {

View File

@ -24,7 +24,9 @@ Vue.use(GoodsActionIcon);
</van-goods-action> </van-goods-action>
``` ```
```javascript ```js
import { Toast } from 'vant';
export default { export default {
methods: { methods: {
onClickIcon() { onClickIcon() {

View File

@ -13,7 +13,7 @@ Vue.use(ImagePreview);
### Basic Usage ### Basic Usage
```javascript ```js
ImagePreview([ ImagePreview([
'https://img.yzcdn.cn/vant/apple-1.jpg', 'https://img.yzcdn.cn/vant/apple-1.jpg',
'https://img.yzcdn.cn/vant/apple-2.jpg' 'https://img.yzcdn.cn/vant/apple-2.jpg'
@ -22,7 +22,7 @@ ImagePreview([
### Custom config ### Custom config
```javascript ```js
ImagePreview({ ImagePreview({
images: [ images: [
'https://img.yzcdn.cn/vant/apple-1.jpg', 'https://img.yzcdn.cn/vant/apple-1.jpg',
@ -37,7 +37,7 @@ ImagePreview({
### Async Close ### Async Close
```javascript ```js
const instance = ImagePreview({ const instance = ImagePreview({
images: [ images: [
'https://img.yzcdn.cn/vant/apple-1.jpg', 'https://img.yzcdn.cn/vant/apple-1.jpg',

View File

@ -17,7 +17,7 @@ Vue.use(ImagePreview);
直接传入图片数组,即可展示图片预览 直接传入图片数组,即可展示图片预览
```javascript ```js
ImagePreview([ ImagePreview([
'https://img.yzcdn.cn/1.jpg', 'https://img.yzcdn.cn/1.jpg',
'https://img.yzcdn.cn/2.jpg' 'https://img.yzcdn.cn/2.jpg'
@ -28,7 +28,7 @@ ImagePreview([
通过传入配置对象,可以指定初始图片的位置、监听关闭事件 通过传入配置对象,可以指定初始图片的位置、监听关闭事件
```javascript ```js
ImagePreview({ ImagePreview({
images: [ images: [
'https://img.yzcdn.cn/1.jpg', 'https://img.yzcdn.cn/1.jpg',
@ -45,7 +45,7 @@ ImagePreview({
通过`asyncClose`属性可以开启异步关闭,开启后异步关闭后,只能通过实例上的 close 方法关闭图片预览 通过`asyncClose`属性可以开启异步关闭,开启后异步关闭后,只能通过实例上的 close 方法关闭图片预览
```javascript ```js
const instance = ImagePreview({ const instance = ImagePreview({
images: [ images: [
'https://img.yzcdn.cn/1.jpg', 'https://img.yzcdn.cn/1.jpg',

View File

@ -22,7 +22,7 @@ Vue.use(Lazyload, {
<img v-for="img in imageList" v-lazy="img" > <img v-for="img in imageList" v-lazy="img" >
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {

View File

@ -26,7 +26,7 @@ Vue.use(Lazyload, {
<img v-for="img in imageList" v-lazy="img" > <img v-for="img in imageList" v-lazy="img" >
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {

View File

@ -25,6 +25,8 @@ Vue.use(NavBar);
``` ```
```js ```js
import { Toast } from 'vant';
export default { export default {
methods: { methods: {
onClickLeft() { onClickLeft() {

View File

@ -25,6 +25,8 @@ Vue.use(NavBar);
``` ```
```js ```js
import { Toast } from 'vant';
export default { export default {
methods: { methods: {
onClickLeft() { onClickLeft() {

View File

@ -28,14 +28,15 @@ Vue.use(NumberKeyboard);
/> />
``` ```
```javascript ```js
import { Toast } from 'vant';
export default { export default {
data() { data() {
return { return {
show: true show: true
} }
}, },
methods: { methods: {
onInput(value) { onInput(value) {
Toast(value); Toast(value);
@ -79,7 +80,7 @@ export default {
/> />
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {

View File

@ -32,14 +32,15 @@ Vue.use(NumberKeyboard);
/> />
``` ```
```javascript ```js
import { Toast } from 'vant';
export default { export default {
data() { data() {
return { return {
show: true show: true
} }
}, },
methods: { methods: {
onInput(value) { onInput(value) {
Toast(value); Toast(value);
@ -85,7 +86,7 @@ export default {
/> />
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {

View File

@ -21,7 +21,7 @@ Vue.use(Pagination);
/> />
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {

View File

@ -22,7 +22,7 @@ Vue.use(Pagination);
/> />
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {

View File

@ -36,7 +36,7 @@ Vue.use(NumberKeyboard);
/> />
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {
@ -101,7 +101,7 @@ Use `error-info` prop to set error message. For example, a password error is pro
/> />
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {

View File

@ -36,7 +36,7 @@ Vue.use(NumberKeyboard);
/> />
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {
@ -101,7 +101,7 @@ export default {
/> />
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {

View File

@ -21,7 +21,9 @@ Vue.use(Picker);
<van-picker :columns="columns" @change="onChange" /> <van-picker :columns="columns" @change="onChange" />
``` ```
```javascript ```js
import { Toast } from 'vant';
export default { export default {
data() { data() {
return { return {
@ -58,7 +60,9 @@ export default {
/> />
``` ```
```javascript ```js
import { Toast } from 'vant';
export default { export default {
data() { data() {
return { return {
@ -122,7 +126,7 @@ export default {
<van-picker :columns="columns" /> <van-picker :columns="columns" />
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {
@ -142,7 +146,7 @@ export default {
<van-picker :columns="columns" @change="onChange" /> <van-picker :columns="columns" @change="onChange" />
``` ```
```javascript ```js
const states = { const states = {
'Group1': ['Delaware', 'Florida', 'Georqia', 'Indiana', 'Maine'], 'Group1': ['Delaware', 'Florida', 'Georqia', 'Indiana', 'Maine'],
'Group2': ['Alabama', 'Kansas', 'Louisiana', 'Texas'] 'Group2': ['Alabama', 'Kansas', 'Louisiana', 'Texas']

View File

@ -23,7 +23,9 @@ Vue.use(Picker);
<van-picker :columns="columns" @change="onChange" /> <van-picker :columns="columns" @change="onChange" />
``` ```
```javascript ```js
import { Toast } from 'vant';
export default { export default {
data() { data() {
return { return {
@ -64,7 +66,9 @@ export default {
/> />
``` ```
```javascript ```js
import { Toast } from 'vant';
export default { export default {
data() { data() {
return { return {
@ -130,7 +134,7 @@ export default {
<van-picker :columns="columns" /> <van-picker :columns="columns" />
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {
@ -150,7 +154,7 @@ export default {
<van-picker :columns="columns" @change="onChange" /> <van-picker :columns="columns" @change="onChange" />
``` ```
```javascript ```js
const citys = { const citys = {
'浙江': ['杭州', '宁波', '温州', '嘉兴', '湖州'], '浙江': ['杭州', '宁波', '温州', '嘉兴', '湖州'],
'福建': ['福州', '厦门', '莆田', '三明', '泉州'] '福建': ['福州', '厦门', '莆田', '三明', '泉州']

View File

@ -19,7 +19,7 @@ Vue.use(Popup);
<van-popup v-model="show">Content</van-popup> <van-popup v-model="show">Content</van-popup>
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {

View File

@ -25,7 +25,7 @@ Vue.use(Popup);
<van-popup v-model="show">内容</van-popup> <van-popup v-model="show">内容</van-popup>
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {

View File

@ -21,7 +21,9 @@ The `refresh` event will be triggered when pull refresh, you should set `v-model
</van-pull-refresh> </van-pull-refresh>
``` ```
```javascript ```js
import { Toast } from 'vant';
export default { export default {
data() { data() {
return { return {
@ -29,11 +31,10 @@ export default {
isLoading: false isLoading: false
} }
}, },
methods: { methods: {
onRefresh() { onRefresh() {
setTimeout(() => { setTimeout(() => {
this.$toast('Refresh Success'); Toast('Refresh Success');
this.isLoading = false; this.isLoading = false;
this.count++; this.count++;
}, 1000); }, 1000);

View File

@ -21,7 +21,9 @@ Vue.use(PullRefresh);
</van-pull-refresh> </van-pull-refresh>
``` ```
```javascript ```js
import { Toast } from 'vant';
export default { export default {
data() { data() {
return { return {
@ -29,11 +31,10 @@ export default {
isLoading: false isLoading: false
} }
}, },
methods: { methods: {
onRefresh() { onRefresh() {
setTimeout(() => { setTimeout(() => {
this.$toast('刷新成功'); Toast('刷新成功');
this.isLoading = false; this.isLoading = false;
this.count++; this.count++;
}, 1000); }, 1000);

View File

@ -23,7 +23,7 @@ Use `v-model` to bind the name of checked radio
</van-radio-group> </van-radio-group>
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {

View File

@ -23,7 +23,7 @@ Vue.use(RadioGroup);
</van-radio-group> </van-radio-group>
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {

View File

@ -17,7 +17,7 @@ Vue.use(Rate);
<van-rate v-model="value" /> <van-rate v-model="value" />
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {
@ -60,7 +60,7 @@ export default {
/> />
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {

View File

@ -17,7 +17,7 @@ Vue.use(Rate);
<van-rate v-model="value" /> <van-rate v-model="value" />
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {
@ -60,7 +60,7 @@ export default {
/> />
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {

View File

@ -17,7 +17,7 @@ Vue.use(Search);
<van-search placeholder="Placeholder" v-model="value" /> <van-search placeholder="Placeholder" v-model="value" />
``` ```
```javascript ```js
export default { export default {
data() { data() {
value: '' value: ''

View File

@ -63,6 +63,8 @@ export default {
``` ```
```js ```js
import { Notify } from 'vant';
export default { export default {
data() { data() {
return { return {

View File

@ -72,6 +72,8 @@ export default {
``` ```
```js ```js
import { Notify } from 'vant';
export default { export default {
data() { data() {
return { return {

View File

@ -2,7 +2,7 @@
### Install ### Install
```javascript ```js
import Vue from 'vue'; import Vue from 'vue';
import { Sku } from 'vant'; import { Sku } from 'vant';
@ -182,7 +182,7 @@ Use [ref](https://vuejs.org/v2/api/#ref) to get Sku instance and call instance m
### Sku Data Structure ### Sku Data Structure
```javascript ```js
sku: { sku: {
tree: [ tree: [
{ {
@ -253,7 +253,7 @@ sku: {
### properties Data Structure ### properties Data Structure
```javascript ```js
[ [
{ {
k_id: 123, k_id: 123,
@ -277,7 +277,7 @@ sku: {
### initialSku Data Structure ### initialSku Data Structure
```javascript ```js
{ {
// KeyskuKeyStr // KeyskuKeyStr
// ValueskuValueId // ValueskuValueId
@ -292,7 +292,7 @@ sku: {
### Goods Data Structure ### Goods Data Structure
```javascript ```js
goods: { goods: {
title: 'Title', title: 'Title',
picture: 'https://img.yzcdn.cn/1.jpg' picture: 'https://img.yzcdn.cn/1.jpg'
@ -302,7 +302,7 @@ goods: {
### customStepperConfig Data Structure ### customStepperConfig Data Structure
```javascript ```js
customStepperConfig: { customStepperConfig: {
// custom quota text // custom quota text
quotaText: 'only 5 can buy', quotaText: 'only 5 can buy',
@ -334,7 +334,7 @@ customStepperConfig: {
### messageConfig Data Structure ### messageConfig Data Structure
```javascript ```js
messageConfig: { messageConfig: {
// the upload image callback // the upload image callback
uploadImg: () => { uploadImg: () => {
@ -355,7 +355,7 @@ messageConfig: {
### Events Params Data Structure ### Events Params Data Structure
```javascript ```js
skuData: { skuData: {
goodsId: '946755', goodsId: '946755',
messages: { messages: {

View File

@ -2,7 +2,7 @@
### 引入 ### 引入
```javascript ```js
import Vue from 'vue'; import Vue from 'vue';
import { Sku } from 'vant'; import { Sku } from 'vant';
@ -188,7 +188,7 @@ Sku 组件默认划分好了若干区块,这些区块都定义成了插槽,
### sku 对象结构 ### sku 对象结构
```javascript ```js
sku: { sku: {
// 所有sku规格类目与其值的从属关系比如商品有颜色和尺码两大类规格颜色下面又有红色和蓝色两个规格值。 // 所有sku规格类目与其值的从属关系比如商品有颜色和尺码两大类规格颜色下面又有红色和蓝色两个规格值。
// 可以理解为一个商品可以有多个规格类目,一个规格类目下可以有多个规格值。 // 可以理解为一个商品可以有多个规格类目,一个规格类目下可以有多个规格值。
@ -244,7 +244,7 @@ sku: {
### properties 对象结构 ### properties 对象结构
```javascript ```js
[ // 商品属性 [ // 商品属性
{ {
k_id: 123, // 属性id k_id: 123, // 属性id
@ -268,7 +268,7 @@ sku: {
### initialSku 对象结构 ### initialSku 对象结构
```javascript ```js
{ {
// 键skuKeyStrsku 组合列表中当前类目对应的 key 值) // 键skuKeyStrsku 组合列表中当前类目对应的 key 值)
// 值skuValueId规格值 id // 值skuValueId规格值 id
@ -287,7 +287,7 @@ sku: {
### goods 对象结构 ### goods 对象结构
```javascript ```js
goods: { goods: {
// 商品标题 // 商品标题
title: '测试商品', title: '测试商品',
@ -298,7 +298,7 @@ goods: {
### customStepperConfig 对象结构 ### customStepperConfig 对象结构
```javascript ```js
customStepperConfig: { customStepperConfig: {
// 自定义限购文案 // 自定义限购文案
quotaText: '每次限购xxx件', quotaText: '每次限购xxx件',
@ -330,7 +330,7 @@ customStepperConfig: {
### messageConfig Data Structure ### messageConfig Data Structure
```javascript ```js
messageConfig: { messageConfig: {
// 图片上传回调需要返回一个promisepromise正确执行的结果需要是一个图片url // 图片上传回调需要返回一个promisepromise正确执行的结果需要是一个图片url
uploadImg: () => { uploadImg: () => {
@ -351,7 +351,7 @@ messageConfig: {
### 添加购物车和点击购买回调函数接收的 skuData 对象结构 ### 添加购物车和点击购买回调函数接收的 skuData 对象结构
```javascript ```js
skuData: { skuData: {
// 商品 id // 商品 id
goodsId: '946755', goodsId: '946755',

View File

@ -18,16 +18,17 @@ Vue.use(Slider);
``` ```
```js ```js
import { Toast } from 'vant';
export default { export default {
data() { data() {
return { return {
value: 50 value: 50
}; };
}, },
methods: { methods: {
onChange(value) { onChange(value) {
this.$toast('Current value' + value); Toast('Current value' + value);
} }
} }
}; };

View File

@ -18,16 +18,17 @@ Vue.use(Slider);
``` ```
```js ```js
import { Toast } from 'vant';
export default { export default {
data() { data() {
return { return {
value: 50 value: 50
}; };
}, },
methods: { methods: {
onChange(value) { onChange(value) {
this.$toast('当前值:' + value); Toast('当前值:' + value);
} }
} }
}; };

View File

@ -17,7 +17,7 @@ Vue.use(Stepper);
<van-stepper v-model="value" /> <van-stepper v-model="value" />
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {
@ -79,14 +79,15 @@ export default {
/> />
``` ```
```javascript ```js
import { Toast } from 'vant';
export default { export default {
data() { data() {
return { return {
value: 1 value: 1
} }
}, },
methods: { methods: {
onChange(value) { onChange(value) {
Toast.loading({ forbidClick: true }); Toast.loading({ forbidClick: true });

View File

@ -23,7 +23,7 @@ Vue.use(Stepper);
<van-stepper v-model="value" /> <van-stepper v-model="value" />
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {
@ -101,14 +101,15 @@ export default {
/> />
``` ```
```javascript ```js
import { Toast } from 'vant';
export default { export default {
data() { data() {
return { return {
value: 1 value: 1
} }
}, },
methods: { methods: {
onChange(value) { onChange(value) {
Toast.loading({ forbidClick: true }); Toast.loading({ forbidClick: true });

View File

@ -23,7 +23,7 @@ Vue.use(Steps);
</van-steps> </van-steps>
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {

View File

@ -23,7 +23,7 @@ Vue.use(Steps);
</van-steps> </van-steps>
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {

View File

@ -37,7 +37,7 @@ Use [Lazyload](#/en-US/lazyload) component to lazyload image
</van-swipe> </van-swipe>
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {
@ -62,6 +62,8 @@ export default {
``` ```
```js ```js
import { Toast } from 'vant';
export default { export default {
methods: { methods: {
onChange(index) { onChange(index) {

View File

@ -37,7 +37,7 @@ Vue.use(SwipeItem);
</van-swipe> </van-swipe>
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {
@ -62,6 +62,8 @@ export default {
``` ```
```js ```js
import { Toast } from 'vant';
export default { export default {
methods: { methods: {
onChange(index) { onChange(index) {

View File

@ -23,7 +23,7 @@ Vue.use(SwitchCell);
</van-cell-group> </van-cell-group>
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {

View File

@ -23,7 +23,7 @@ Vue.use(SwitchCell);
</van-cell-group> </van-cell-group>
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {

View File

@ -17,7 +17,7 @@ Vue.use(Switch);
<van-switch v-model="checked" /> <van-switch v-model="checked" />
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {

View File

@ -19,7 +19,7 @@ Vue.use(Switch);
<van-switch v-model="checked" /> <van-switch v-model="checked" />
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {

View File

@ -78,11 +78,13 @@ You can set `disabled` attribute on the corresponding `van-tab`.
</van-tabs> </van-tabs>
``` ```
```javascript ```js
import { Toast } from 'vant';
export default { export default {
methods: { methods: {
onClickDisabled(name, title) { onClickDisabled(name, title) {
this.$toast(title + ' is disabled'); Toast(title + ' is disabled');
} }
} }
}; };
@ -110,11 +112,13 @@ Tabs styled as cards.
</van-tabs> </van-tabs>
``` ```
```javascript ```js
import { Toast } from 'vant';
export default { export default {
methods: { methods: {
onClick(name, title) { onClick(name, title) {
this.$toast(title); Toast(title);
} }
} }
}; };

View File

@ -81,11 +81,13 @@ export default {
</van-tabs> </van-tabs>
``` ```
```javascript ```js
import { Toast } from 'vant';
export default { export default {
methods: { methods: {
onClickDisabled(name, title) { onClickDisabled(name, title) {
this.$toast(name + '已被禁用'); Toast(name + '已被禁用');
} }
} }
}; };
@ -114,11 +116,13 @@ export default {
</van-tabs> </van-tabs>
``` ```
```javascript ```js
import { Toast } from 'vant';
export default { export default {
methods: { methods: {
onClick(name, title) { onClick(name, title) {
this.$toast(title); Toast(title);
} }
} }
}; };

View File

@ -23,7 +23,7 @@ Vue.use(TabbarItem);
</van-tabbar> </van-tabbar>
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {
@ -44,7 +44,7 @@ export default {
</van-tabbar> </van-tabbar>
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {
@ -84,7 +84,7 @@ Use `icon` slot to custom icon
</van-tabbar> </van-tabbar>
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {
@ -126,6 +126,8 @@ export default {
``` ```
```js ```js
import { Notify } from 'vant';
export default { export default {
methods: { methods: {
onChange(index) { onChange(index) {

View File

@ -25,7 +25,7 @@ Vue.use(TabbarItem);
</van-tabbar> </van-tabbar>
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {
@ -48,7 +48,7 @@ export default {
</van-tabbar> </van-tabbar>
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {
@ -90,7 +90,7 @@ export default {
</van-tabbar> </van-tabbar>
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {
@ -131,6 +131,8 @@ export default {
``` ```
```js ```js
import { Notify } from 'vant';
export default { export default {
methods: { methods: {
onChange(index) { onChange(index) {

View File

@ -2,7 +2,7 @@
### Install ### Install
```javascript ```js
import Vue from 'vue'; import Vue from 'vue';
import { Toast } from 'vant'; import { Toast } from 'vant';
@ -13,13 +13,13 @@ Vue.use(Toast);
### Text ### Text
```javascript ```js
Toast('Some messages'); Toast('Some messages');
``` ```
### Loading ### Loading
```javascript ```js
Toast.loading({ Toast.loading({
message: 'Loading...', message: 'Loading...',
forbidClick: true forbidClick: true
@ -34,7 +34,7 @@ Toast.loading({
### Success/Fail ### Success/Fail
```javascript ```js
Toast.success('Success'); Toast.success('Success');
Toast.fail('Fail'); Toast.fail('Fail');
``` ```
@ -55,7 +55,7 @@ Toast({
### Update Message ### Update Message
```javascript ```js
const toast = Toast.loading({ const toast = Toast.loading({
duration: 0, // continuous display toast duration: 0, // continuous display toast
forbidClick: true, forbidClick: true,

View File

@ -21,7 +21,7 @@ Vue.use(TreeSelect);
/> />
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {
@ -43,7 +43,7 @@ export default {
/> />
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {
@ -136,7 +136,7 @@ export default {
In every tree object, `text` property defines `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 ```js
[ [
{ {
// name of the parent node // name of the parent node

View File

@ -23,7 +23,7 @@ Vue.use(TreeSelect);
/> />
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {
@ -47,7 +47,7 @@ export default {
/> />
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {
@ -142,7 +142,7 @@ export default {
`items` 整体为一个数组,数组内包含一系列描述分类的对象,每个分类里,`text`表示当前分类的名称,`children`表示分类里的可选项。 `items` 整体为一个数组,数组内包含一系列描述分类的对象,每个分类里,`text`表示当前分类的名称,`children`表示分类里的可选项。
```javascript ```js
[ [
{ {
// 导航名称 // 导航名称

View File

@ -17,7 +17,7 @@ Vue.use(Uploader);
<van-uploader :after-read="afterRead" /> <van-uploader :after-read="afterRead" />
``` ```
```javascript ```js
export default { export default {
methods: { methods: {
afterRead(file) { afterRead(file) {
@ -33,7 +33,7 @@ export default {
<van-uploader v-model="fileList" multiple /> <van-uploader v-model="fileList" multiple />
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {
@ -55,7 +55,7 @@ export default {
/> />
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {
@ -80,6 +80,8 @@ export default {
``` ```
```js ```js
import { Toast } from 'vant';
export default { export default {
methods: { methods: {
beforeRead(file) { beforeRead(file) {
@ -90,7 +92,6 @@ export default {
return true; return true;
}, },
asyncBeforeRead(file) { asyncBeforeRead(file) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (file.type !== 'image/jpeg') { if (file.type !== 'image/jpeg') {

View File

@ -19,7 +19,7 @@ Vue.use(Uploader);
<van-uploader :after-read="afterRead" /> <van-uploader :after-read="afterRead" />
``` ```
```javascript ```js
export default { export default {
methods: { methods: {
afterRead(file) { afterRead(file) {
@ -38,7 +38,7 @@ export default {
<van-uploader v-model="fileList" multiple /> <van-uploader v-model="fileList" multiple />
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {
@ -65,7 +65,7 @@ export default {
/> />
``` ```
```javascript ```js
export default { export default {
data() { data() {
return { return {
@ -94,6 +94,8 @@ export default {
``` ```
```js ```js
import { Toast } from 'vant';
export default { export default {
methods: { methods: {
// 返回布尔值 // 返回布尔值
@ -105,7 +107,6 @@ export default {
return true; return true;
}, },
// 返回 Promise // 返回 Promise
asyncBeforeRead(file) { asyncBeforeRead(file) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {