1
0
mirror of https://gitee.com/vant-contrib/vant.git synced 2025-04-06 03:57:59 +08:00

types: fix ts errors in demo files ()

* types: fix ts errors in demo files

* docs: upd
This commit is contained in:
neverland 2022-02-09 14:56:44 +08:00 committed by GitHub
parent 7630bb2c03
commit b5d0fec611
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 33 additions and 21 deletions
packages
vant-cli/site/desktop/components
vant/src
contact-edit
count-down
notify/demo
slider/demo
stepper/demo
sticky/demo
swipe-cell/demo
tab/demo
uploader

@ -262,7 +262,7 @@ export default {
&__subtitle { &__subtitle {
display: inline-block; display: inline-block;
color: #999; color: #999;
margin-left: 8px; margin-left: 4px;
vertical-align: -4px; vertical-align: -4px;
font-size: 13px; font-size: 13px;
} }

@ -37,7 +37,10 @@ import { Toast } from 'vant';
export default { export default {
setup() { setup() {
const editingContact = ref({}); const editingContact = ref({
tel: '',
name: '',
});
const onSave = (contactInfo) => Toast('Save'); const onSave = (contactInfo) => Toast('Save');
const onDelete = (contactInfo) => Toast('Delete'); const onDelete = (contactInfo) => Toast('Delete');
return { return {

@ -37,7 +37,10 @@ import { Toast } from 'vant';
export default { export default {
setup() { setup() {
const editingContact = ref({}); const editingContact = ref({
tel: '',
name: '',
});
const onSave = (contactInfo) => Toast('保存'); const onSave = (contactInfo) => Toast('保存');
const onDelete = (contactInfo) => Toast('删除'); const onDelete = (contactInfo) => Toast('删除');
return { return {

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import VanContactEdit from '..';
import { ref } from 'vue'; import { ref } from 'vue';
import VanContactEdit, { type ContactEditInfo } from '..';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site/use-translate';
import { Toast } from '../../toast'; import { Toast } from '../../toast';
@ -13,7 +13,10 @@ const t = useTranslate({
}, },
}); });
const editingContact = ref({}); const editingContact = ref<ContactEditInfo>({
tel: '',
name: '',
});
const onSave = () => Toast(t('save')); const onSave = () => Toast(t('save'));
const onDelete = () => Toast(t('delete')); const onDelete = () => Toast(t('delete'));

@ -1,11 +1,10 @@
<script setup lang="ts"> <script setup lang="ts">
import VanCountDown from '..';
import VanGrid from '../../grid'; import VanGrid from '../../grid';
import VanGridItem from '../../grid-item'; import VanGridItem from '../../grid-item';
import VanCountDown, { type CountDownInstance } from '..';
import { ref } from 'vue'; import { ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site/use-translate';
import { Toast } from '../../toast'; import { Toast } from '../../toast';
import type { CountDownInstance } from '../CountDown';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

@ -1,7 +1,10 @@
import { KeepAlive, nextTick } from 'vue'; import { nextTick, KeepAlive } from 'vue';
import { CountDown } from '..'; import {
CountDown,
type CountDownInstance,
type CountDownCurrentTime,
} from '..';
import { mount, later } from '../../../test'; import { mount, later } from '../../../test';
import type { CountDownCurrentTime, CountDownInstance } from '../CountDown';
test('should emit finish event when finished', async () => { test('should emit finish event when finished', async () => {
const wrapper = mount(CountDown, { const wrapper = mount(CountDown, {

@ -1,10 +1,9 @@
<script setup lang="ts"> <script setup lang="ts">
import VanCell from '../../cell'; import VanCell from '../../cell';
import VanIcon from '../../icon'; import VanIcon from '../../icon';
import { Notify } from '..';
import { ref } from 'vue'; import { ref } from 'vue';
import { Notify, type NotifyType } from '..';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site/use-translate';
import { NotifyType } from '../Notify';
const VanNotify = Notify.Component; const VanNotify = Notify.Component;

@ -30,14 +30,14 @@ const t = useTranslate({
}); });
const value1 = ref(50); const value1 = ref(50);
const value2 = ref([20, 60]); const value2 = ref<[number, number]>([20, 60]);
const value3 = ref(0); const value3 = ref(0);
const value4 = ref(50); const value4 = ref(50);
const value5 = ref(50); const value5 = ref(50);
const value6 = ref(50); const value6 = ref(50);
const value7 = ref(50); const value7 = ref(50);
const value8 = ref(50); const value8 = ref(50);
const value9 = ref([20, 60]); const value9 = ref<[number, number]>([20, 60]);
const onChange = (value: string) => Toast(t('text') + value); const onChange = (value: string) => Toast(t('text') + value);
</script> </script>

@ -42,7 +42,7 @@ const disabledInput = ref(1);
const beforeChange = () => { const beforeChange = () => {
Toast.loading({ forbidClick: true }); Toast.loading({ forbidClick: true });
return new Promise((resolve) => { return new Promise<boolean>((resolve) => {
setTimeout(() => { setTimeout(() => {
Toast.clear(); Toast.clear();
resolve(true); resolve(true);

@ -17,7 +17,7 @@ const t = useTranslate({
}, },
}); });
const container = ref(null); const container = ref<Element>();
</script> </script>
<template> <template>

@ -38,10 +38,12 @@ const beforeClose = ({ position }: { position: string }) => {
case 'outside': case 'outside':
return true; return true;
case 'right': case 'right':
return new Promise((resolve) => { return new Promise<boolean>((resolve) => {
Dialog.confirm({ Dialog.confirm({
title: t('confirm'), title: t('confirm'),
}).then(resolve); }).then(() => {
resolve(true);
});
}); });
} }
}; };

@ -64,7 +64,7 @@ const beforeChange = (name: number) => {
if (name === 1) { if (name === 1) {
return false; return false;
} }
return new Promise((resolve) => { return new Promise<boolean>((resolve) => {
resolve(name !== 3); resolve(name !== 3);
}); });
}; };

@ -99,7 +99,7 @@ test('set input name', (done) => {
detail: { name: string | number; index: number } detail: { name: string | number; index: number }
) => { ) => {
expect(detail.name).toEqual('uploader'); expect(detail.name).toEqual('uploader');
return file; return true;
}, },
afterRead: ( afterRead: (
readFile: UploaderFileListItem | UploaderFileListItem[], readFile: UploaderFileListItem | UploaderFileListItem[],

@ -26,7 +26,7 @@ export type UploaderBeforeRead = (
name: string | number; name: string | number;
index: number; index: number;
} }
) => boolean | Promise<File | File[] | undefined>; ) => boolean | undefined | Promise<File | File[] | undefined>;
export type UploaderAfterRead = ( export type UploaderAfterRead = (
items: UploaderFileListItem | UploaderFileListItem[], items: UploaderFileListItem | UploaderFileListItem[],