docs: prefer shorter demo

This commit is contained in:
chenjiahan 2021-01-20 21:00:36 +08:00
parent 3787e82ec7
commit cb3219ab66
57 changed files with 95 additions and 315 deletions

View File

@ -30,12 +30,8 @@ import { Toast } from 'vant';
export default {
setup() {
const onClickIcon = () => {
Toast('Click Icon');
};
const onClickButton = () => {
Toast('Click Button');
};
const onClickIcon = () => Toast('Click Icon');
const onClickButton = () => Toast('Click Button');
return {
onClickIcon,
onClickButton,

View File

@ -30,12 +30,8 @@ import { Toast } from 'vant';
export default {
setup() {
const onClickIcon = () => {
Toast('点击图标');
};
const onClickButton = () => {
Toast('点击按钮');
};
const onClickIcon = () => Toast('点击图标');
const onClickButton = () => Toast('点击按钮');
return {
onClickIcon,
onClickButton,

View File

@ -98,15 +98,8 @@ const i18n = {
export default {
setup() {
const t = useTranslate(i18n);
const onClickIcon = () => {
Toast(t('clickIcon'));
};
const onClickButton = () => {
Toast(t('clickButton'));
};
const onClickIcon = () => Toast(t('clickIcon'));
const onClickButton = () => Toast(t('clickButton'));
return {
t,
onClickIcon,

View File

@ -71,9 +71,7 @@ export default {
{ name: 'Option 2' },
{ name: 'Option 3' },
];
const onCancel = () => {
Toast('cancel');
};
const onCancel = () => Toast('cancel');
return {
show,

View File

@ -79,9 +79,7 @@ export default {
{ name: '选项二' },
{ name: '选项三' },
];
const onCancel = () => {
Toast('取消');
};
const onCancel = () => Toast('取消');
return {
show,

View File

@ -122,10 +122,7 @@ export default {
state.show.basic = false;
Toast(item.name);
};
const onCancel = () => {
Toast(t('cancel'));
};
const onCancel = () => Toast(t('cancel'));
return {
...toRefs(state),

View File

@ -37,12 +37,8 @@ export default {
setup() {
const searchResult = ref([]);
const onSave = () => {
Toast('save');
};
const onDelete = () => {
Toast('delete');
};
const onSave = () => Toast('save');
const onDelete = () => Toast('delete');
const onChangeDetail = (val) => {
if (val) {
searchResult.value = [

View File

@ -41,12 +41,8 @@ export default {
setup() {
const searchResult = ref([]);
const onSave = () => {
Toast('save');
};
const onDelete = () => {
Toast('delete');
};
const onSave = () => Toast('save');
const onDelete = () => Toast('delete');
const onChangeDetail = (val) => {
if (val) {
searchResult.value = [

View File

@ -61,14 +61,8 @@ export default {
const t = useTranslate(i18n);
const searchResult = ref([]);
const onSave = () => {
Toast(t('save'));
};
const onDelete = () => {
Toast(t('delete'));
};
const onSave = () => Toast(t('save'));
const onDelete = () => Toast(t('delete'));
const onChangeDetail = (val: string) => {
searchResult.value = val ? t('searchResult') : [];
};

View File

@ -57,12 +57,8 @@ export default {
},
];
const onAdd = () => {
Toast('Add');
};
const onEdit = (item, index) => {
Toast('Edit:' + index);
};
const onAdd = () => Toast('Add');
const onEdit = (item, index) => Toast('Edit:' + index);
return {
list,

View File

@ -61,12 +61,8 @@ export default {
},
];
const onAdd = () => {
Toast('新增地址');
};
const onEdit = (item, index) => {
Toast('编辑地址:' + index);
};
const onAdd = () => Toast('新增地址');
const onEdit = (item, index) => Toast('编辑地址:' + index);
return {
list,

View File

@ -23,9 +23,7 @@ import { Toast } from 'vant';
export default {
setup() {
const onAdd = () => {
Toast('add');
};
const onAdd = () => Toast('add');
return {
onAdd,
};
@ -54,10 +52,7 @@ export default {
name: 'John Snow',
tel: '13000000000',
});
const onEdit = () => {
Toast('edit');
};
const onEdit = () => Toast('edit');
return {
onEdit,

View File

@ -27,9 +27,7 @@ import { Toast } from 'vant';
export default {
setup() {
const onAdd = () => {
Toast('新增');
};
const onAdd = () => Toast('新增');
return {
onAdd,
};
@ -58,10 +56,7 @@ export default {
name: '张三',
tel: '13000000000',
});
const onEdit = () => {
Toast('edit');
};
const onEdit = () => Toast('edit');
return {
onEdit,

View File

@ -53,13 +53,8 @@ export default {
tel: '13000000000',
}));
const onAdd = () => {
Toast(t('add'));
};
const onEdit = () => {
Toast(t('edit'));
};
const onAdd = () => Toast(t('add'));
const onEdit = () => Toast(t('edit'));
return {
t,

View File

@ -32,13 +32,8 @@ import { Toast } from 'vant';
export default {
setup() {
const editingContact = ref({});
const onSave = (contactInfo) => {
Toast('Save');
};
const onDelete = (contactInfo) => {
Toast('Delete');
};
const onSave = (contactInfo) => Toast('Save');
const onDelete = (contactInfo) => Toast('Delete');
return {
onSave,
onDelete,

View File

@ -36,13 +36,8 @@ import { Toast } from 'vant';
export default {
setup() {
const editingContact = ref({});
const onSave = (contactInfo) => {
Toast('保存');
};
const onDelete = (contactInfo) => {
Toast('删除');
};
const onSave = (contactInfo) => Toast('保存');
const onDelete = (contactInfo) => Toast('删除');
return {
onSave,
onDelete,

View File

@ -30,12 +30,8 @@ export default {
const t = useTranslate(i18n);
const editingContact = ref({});
const onSave = () => {
Toast(t('save'));
};
const onDelete = () => {
Toast(t('delete'));
};
const onSave = () => Toast(t('save'));
const onDelete = () => Toast(t('delete'));
return {
t,

View File

@ -48,15 +48,9 @@ export default {
],
});
const onAdd = () => {
Toast('Add');
};
const onEdit = (contact) => {
Toast('Edit' + contact.id);
};
const onSelect = (contact) => {
Toast('Select' + contact.id);
};
const onAdd = () => Toast('Add');
const onEdit = (contact) => Toast('Edit' + contact.id);
const onSelect = (contact) => Toast('Select' + contact.id);
return {
state,

View File

@ -52,15 +52,9 @@ export default {
],
});
const onAdd = () => {
Toast('新增');
};
const onEdit = (contact) => {
Toast('编辑' + contact.id);
};
const onSelect = (contact) => {
Toast('选择' + contact.id);
};
const onAdd = () => Toast('新增');
const onEdit = (contact) => Toast('编辑' + contact.id);
const onSelect = (contact) => Toast('选择' + contact.id);
return {
state,

View File

@ -105,9 +105,7 @@ export default {
const reset = () => {
countDown.value.reset();
};
const onFinish = () => {
Toast('Finished');
};
const onFinish = () => Toast('Finished');
return {
start,

View File

@ -119,9 +119,7 @@ export default {
const reset = () => {
countDown.value.reset();
};
const onFinish = () => {
Toast('倒计时结束');
};
const onFinish = () => Toast('倒计时结束');
return {
start,

View File

@ -85,9 +85,7 @@ export default {
const reset = () => {
countDown.value.reset();
};
const onFinish = () => {
Toast(t('finished'));
};
const onFinish = () => Toast(t('finished'));
return {
t,

View File

@ -79,9 +79,7 @@ export default {
index: 0,
});
const onClose = () => {
Toast(t('closed'));
};
const onClose = () => Toast(t('closed'));
const beforeClose = () =>
new Promise((resolve) => {

View File

@ -30,12 +30,8 @@ import { Toast } from 'vant';
export default {
setup() {
const onClickLeft = () => {
Toast('Back');
};
const onClickRight = () => {
Toast('Button');
};
const onClickLeft = () => Toast('Back');
const onClickRight = () => Toast('Button');
return {
onClickLeft,
onClickRight,

View File

@ -30,12 +30,8 @@ import { Toast } from 'vant';
export default {
setup() {
const onClickLeft = () => {
Toast('返回');
};
const onClickRight = () => {
Toast('按钮');
};
const onClickLeft = () => Toast('返回');
const onClickRight = () => Toast('按钮');
return {
onClickLeft,
onClickRight,

View File

@ -35,14 +35,8 @@ const i18n = {
export default {
setup() {
const t = useTranslate(i18n);
const onClickLeft = () => {
Toast(t('back'));
};
const onClickRight = () => {
Toast(t('button'));
};
const onClickLeft = () => Toast(t('back'));
const onClickRight = () => Toast(t('button'));
return {
t,

View File

@ -31,12 +31,8 @@ import { Toast } from 'vant';
export default {
setup() {
const show = ref(true);
const onInput = (value) => {
Toast(value);
};
const onDelete = () => {
Toast('delete');
};
const onInput = (value) => Toast(value);
const onDelete = () => Toast('delete');
return {
show,

View File

@ -37,12 +37,8 @@ import { Toast } from 'vant';
export default {
setup() {
const show = ref(true);
const onInput = (value) => {
Toast(value);
};
const onDelete = () => {
Toast('删除');
};
const onInput = (value) => Toast(value);
const onDelete = () => Toast('删除');
return {
show,

View File

@ -137,13 +137,8 @@ export default {
keyboard: 'default',
});
const onInput = (value: string) => {
Toast(`${t('input')}: ${value}`);
};
const onDelete = () => {
Toast(t('delete'));
};
const onInput = (value: string) => Toast(`${t('input')}: ${value}`);
const onDelete = () => Toast(t('delete'));
return {
...toRefs(state),

View File

@ -41,9 +41,7 @@ export default {
const onChange = (value, index) => {
Toast(`Value: ${value}, Index: ${index}`);
};
const onCancel = () => {
Toast('Cancel');
};
const onCancel = () => Toast('Cancel');
return {
columns,

View File

@ -49,9 +49,7 @@ export default {
const onChange = (value, index) => {
Toast(`当前值: ${value}, 当前索引: ${index}`);
};
const onCancel = () => {
Toast('取消');
};
const onCancel = () => Toast('取消');
return {
columns,

View File

@ -183,9 +183,7 @@ export default {
Toast(t('toastContent', value, index));
};
const onCancel = () => {
Toast(t('cancel'));
};
const onCancel = () => Toast(t('cancel'));
const onCancel2 = () => {
state.showPicker = false;

View File

@ -34,10 +34,7 @@ export default {
{ text: 'Option 2' },
{ text: 'Option 3' },
];
const onSelect = (action) => {
Toast(action.text);
};
const onSelect = (action) => Toast(action.text);
return {
actions,

View File

@ -42,10 +42,7 @@ export default {
{ text: '选项二' },
{ text: '选项三' },
];
const onSelect = (action) => {
Toast(action.text);
};
const onSelect = (action) => Toast(action.text);
return {
actions,

View File

@ -212,9 +212,7 @@ export default {
});
};
const onSelect = (action: { text: string }) => {
Toast(action.text);
};
const onSelect = (action: { text: string }) => Toast(action.text);
return {
...toRefs(state),

View File

@ -95,9 +95,7 @@ import { Toast } from 'vant';
export default {
setup() {
const value = ref(3);
const onChange = (value) => {
Toast('current value:' + value);
};
const onChange = (value) => Toast('current value:' + value);
return {
value,
onChange,

View File

@ -99,9 +99,7 @@ import { Toast } from 'vant';
export default {
setup() {
const value = ref(3);
const onChange = (value) => {
Toast('当前值:' + value);
};
const onChange = (value) => Toast('当前值:' + value);
return {
value,
onChange,

View File

@ -85,9 +85,7 @@ export default {
value7: 2,
});
const onChange = (value) => {
Toast(t('toastContent', value));
};
const onChange = (value) => Toast(t('toastContent', value));
return {
...toRefs(state),

View File

@ -52,12 +52,8 @@ import { Toast } from 'vant';
export default {
setup() {
const value = ref('');
const onSearch = (val) => {
Toast(val);
};
const onCancel = () => {
Toast('Cancel');
};
const onSearch = (val) => Toast(val);
const onCancel = () => Toast('Cancel');
return {
value,
onSearch,

View File

@ -58,12 +58,8 @@ import { Toast } from 'vant';
export default {
setup() {
const value = ref('');
const onSearch = (val) => {
Toast(val);
};
const onCancel = () => {
Toast('取消');
};
const onSearch = (val) => Toast(val);
const onCancel = () => Toast('取消');
return {
value,
onSearch,

View File

@ -89,13 +89,8 @@ export default {
value6: '',
});
const onSearch = (val) => {
Toast(val);
};
const onCancel = () => {
Toast(t('cancel'));
};
const onSearch = (val) => Toast(val);
const onCancel = () => Toast(t('cancel'));
return {
...toRefs(state),

View File

@ -71,10 +71,7 @@ import { Toast } from 'vant';
export default {
setup() {
const active = ref(0);
const onChange = (index) => {
Toast(`Title ${index + 1}`);
};
const onChange = (index) => Toast(`Title ${index + 1}`);
return {
active,
onChange,

View File

@ -79,10 +79,7 @@ import { Toast } from 'vant';
export default {
setup() {
const active = ref(0);
const onChange = (index) => {
Toast(`标签名 ${index + 1}`);
};
const onChange = (index) => Toast(`标签名 ${index + 1}`);
return {
active,
onChange,

View File

@ -67,9 +67,7 @@ export default {
active4: 0,
});
const onChange = (index: number) => {
Toast(`${t('title')} ${index + 1}`);
};
const onChange = (index: number) => Toast(`${t('title')} ${index + 1}`);
return {
...toRefs(state),

View File

@ -25,9 +25,7 @@ import { Toast } from 'vant';
export default {
setup() {
const value = ref(50);
const onChange = (value) => {
Toast('Current value: ' + value);
};
const onChange = (value) => Toast('Current value: ' + value);
return {
value,
onChange,
@ -52,9 +50,7 @@ export default {
setup() {
// value must be an Array
const value = ref([10, 50]);
const onChange = (value) => {
Toast('Current value: ' + value);
};
const onChange = (value) => Toast('Current value: ' + value);
return {
value,
onChange,
@ -132,9 +128,7 @@ export default {
setup() {
const value = ref(50);
const value2 = ref([10, 50]);
const onChange = (value) => {
Toast('Current value: ' + value);
};
const onChange = (value) => Toast('Current value: ' + value);
return {
value,
value2,

View File

@ -29,9 +29,7 @@ import { Toast } from 'vant';
export default {
setup() {
const value = ref(50);
const onChange = (value) => {
Toast('当前值:' + value);
};
const onChange = (value) => Toast('当前值:' + value);
return {
value,
onChange,
@ -56,9 +54,7 @@ export default {
setup() {
// 双滑块模式时,值必须是数组
const value = ref([10, 50]);
const onChange = (value) => {
Toast('当前值:' + value);
};
const onChange = (value) => Toast('当前值:' + value);
return {
value,
onChange,
@ -138,9 +134,7 @@ export default {
setup() {
const value = ref(50);
const value2 = ref([10, 50]);
const onChange = (value) => {
Toast('当前值:' + value);
};
const onChange = (value) => Toast('当前值:' + value);
return {
value,
value2,

View File

@ -95,9 +95,7 @@ export default {
value9: [20, 60],
});
const onChange = (value) => {
Toast(t('text') + value);
};
const onChange = (value) => Toast(t('text') + value);
return {
...toRefs(state),

View File

@ -23,10 +23,7 @@ import { Toast } from 'vant';
export default {
setup() {
const onSubmit = () => {
Toast('Submit');
};
const onSubmit = () => Toast('Submit');
return {
onSubmit,
};
@ -73,13 +70,8 @@ import { Toast } from 'vant';
export default {
setup() {
const onSubmit = () => {
Toast('Submit');
};
const onClickLink = () => {
Toast('Click Link');
};
const onSubmit = () => Toast('Submit');
const onClickLink = () => Toast('Click Link');
return {
onSubmit,
onClickLink,

View File

@ -23,10 +23,7 @@ import { Toast } from 'vant';
export default {
setup() {
const onSubmit = () => {
Toast('点击按钮');
};
const onSubmit = () => Toast('点击按钮');
return {
onSubmit,
};
@ -80,13 +77,8 @@ import { Toast } from 'vant';
export default {
setup() {
const onSubmit = () => {
Toast('点击按钮');
};
const onClickLink = () => {
Toast('修改地址');
};
const onSubmit = () => Toast('点击按钮');
const onClickLink = () => Toast('修改地址');
return {
onSubmit,
onClickLink,

View File

@ -71,12 +71,8 @@ export default {
const t = useTranslate(i18n);
const checked = ref(true);
const onSubmit = () => {
Toast(t('clickButton'));
};
const onClickLink = () => {
Toast(t('clickLink'));
};
const onSubmit = () => Toast(t('clickButton'));
const onClickLink = () => Toast(t('clickLink'));
return {
t,

View File

@ -76,9 +76,7 @@ import { Toast } from 'vant';
export default {
setup() {
const onChange = (index) => {
Toast('Current Swipe index:' + index);
};
const onChange = (index) => Toast('Current Swipe index:' + index);
return { onChange };
},
};

View File

@ -80,9 +80,7 @@ import { Toast } from 'vant';
export default {
setup() {
const onChange = (index) => {
Toast('当前 Swipe 索引:' + index);
};
const onChange = (index) => Toast('当前 Swipe 索引:' + index);
return { onChange };
},
};

View File

@ -98,10 +98,7 @@ export default {
'https://img.yzcdn.cn/vant/apple-4.jpg',
];
const onChange1 = (index) => {
Toast(t('message') + index);
};
const onChange1 = (index) => Toast(t('message') + index);
const onChange2 = (index) => {
current.value = index;
};

View File

@ -86,10 +86,7 @@ import { Toast } from 'vant';
export default {
setup() {
const onClickDisabled = (name, title) => {
Toast(name + ' is disabled');
};
const onClickDisabled = (name, title) => Toast(`${name} is disabled`);
return {
onClickDisabled,
};
@ -124,10 +121,7 @@ import { Toast } from 'vant';
export default {
setup() {
const onClick = (name, title) => {
Toast(title);
};
const onClick = (name, title) => Toast(title);
return {
onClick,
};

View File

@ -89,10 +89,7 @@ import { Toast } from 'vant';
export default {
setup() {
const onClickDisabled = (name, title) => {
Toast(name + '已被禁用');
};
const onClickDisabled = (name, title) => Toast(`${name}已被禁用`);
return {
onClickDisabled,
};
@ -128,10 +125,7 @@ import { Toast } from 'vant';
export default {
setup() {
const onClick = (name, title) => {
Toast(title);
};
const onClick = (name, title) => Toast(title);
return {
onClick,
};

View File

@ -132,10 +132,7 @@ import { Toast } from 'vant';
export default {
setup() {
const active = ref(0);
const onChange = (index) => {
Toast(`Tab ${index}`);
};
const onChange = (index) => Toast(`Tab ${index}`);
return {
icon,
onChange,

View File

@ -138,10 +138,7 @@ import { Toast } from 'vant';
export default {
setup() {
const active = ref(0);
const onChange = (index) => {
Toast(`标签 ${index}`);
};
const onChange = (index) => Toast(`标签 ${index}`);
return {
icon,
onChange,