diff --git a/src/components/FileUpload/index.vue b/src/components/FileUpload/index.vue index fdf7a1c..b173317 100644 --- a/src/components/FileUpload/index.vue +++ b/src/components/FileUpload/index.vue @@ -24,7 +24,13 @@ const props = withDefaults( }, ) -const emit = defineEmits(['onSuccess']) +const emits = defineEmits<{ + 'onSuccess': [ + res: any, + file: UploadUserFile, + fileList: UploadUserFile[], + ] +}>() defineOptions({ name: 'FileUpload', @@ -49,7 +55,7 @@ const onExceed: UploadProps['onExceed'] = () => { } const onSuccess: UploadProps['onSuccess'] = (res, file, fileList) => { - emit('onSuccess', res, file, fileList) + emits('onSuccess', res, file, fileList) } diff --git a/src/components/ImageUpload/index.vue b/src/components/ImageUpload/index.vue index e466431..173544a 100644 --- a/src/components/ImageUpload/index.vue +++ b/src/components/ImageUpload/index.vue @@ -28,7 +28,14 @@ const props = withDefaults( }, ) -const emit = defineEmits(['update:url', 'onSuccess']) +const emits = defineEmits<{ + 'update:url': [ + url: string, + ] + 'onSuccess': [ + res: any, + ] +}>() defineOptions({ name: 'ImageUpload', @@ -52,7 +59,7 @@ function previewClose() { } // 移除 function remove() { - emit('update:url', '') + emits('update:url', '') } const beforeUpload: UploadProps['beforeUpload'] = (file) => { const fileName = file.name.split('.') @@ -76,7 +83,7 @@ const onProgress: UploadProps['onProgress'] = (file) => { const onSuccess: UploadProps['onSuccess'] = (res) => { uploadData.value.progress.preview = '' uploadData.value.progress.percent = 0 - emit('onSuccess', res) + emits('onSuccess', res) } diff --git a/src/components/ImagesUpload/index.vue b/src/components/ImagesUpload/index.vue index e69f8d5..f730350 100644 --- a/src/components/ImagesUpload/index.vue +++ b/src/components/ImagesUpload/index.vue @@ -30,7 +30,14 @@ const props = withDefaults( }, ) -const emit = defineEmits(['update:url', 'onSuccess']) +const emits = defineEmits<{ + 'update:url': [ + value: string[], + ] + 'onSuccess': [ + res: any, + ] +}>() defineOptions({ name: 'ImagesUpload', @@ -58,7 +65,7 @@ function previewClose() { function remove(index: number) { const url = props.url url.splice(index, 1) - emit('update:url', url) + emits('update:url', url) } // 移动 function move(index: number, type: 'left' | 'right') { @@ -69,7 +76,7 @@ function move(index: number, type: 'left' | 'right') { if (type === 'right' && index !== url.length - 1) { url[index] = url.splice(index + 1, 1, url[index])[0] } - emit('update:url', url) + emits('update:url', url) } const beforeUpload: UploadProps['beforeUpload'] = (file) => { @@ -94,7 +101,7 @@ const onProgress: UploadProps['onProgress'] = (file) => { const onSuccess: UploadProps['onSuccess'] = (res) => { uploadData.value.progress.preview = '' uploadData.value.progress.percent = 0 - emit('onSuccess', res) + emits('onSuccess', res) } diff --git a/src/components/PcasCascader/index.vue b/src/components/PcasCascader/index.vue index d9b7b0c..f20efbd 100644 --- a/src/components/PcasCascader/index.vue +++ b/src/components/PcasCascader/index.vue @@ -19,7 +19,14 @@ const props = withDefaults( }, ) -const emit = defineEmits(['update:modelValue']) +const emits = defineEmits<{ + 'update:modelValue': [ + value: string[] | { + code: string + name: string + }[], + ] +}>() defineOptions({ name: 'PcasCascader', @@ -85,7 +92,7 @@ const myValue = computed({ }, // 将 code 码转成出参数据 set: (value) => { - emit('update:modelValue', value ? codeToAny(value) : []) + emits('update:modelValue', value ? codeToAny(value) : []) }, }) diff --git a/src/components/SearchBar/index.vue b/src/components/SearchBar/index.vue index 34876e1..9eb6732 100644 --- a/src/components/SearchBar/index.vue +++ b/src/components/SearchBar/index.vue @@ -12,9 +12,13 @@ const props = withDefaults( }, ) -const emit = defineEmits<{ - (event: 'update:fold', value: boolean): void - (event: 'toggle', value: boolean): void +const emits = defineEmits<{ + 'update:fold': [ + value: boolean, + ] + 'toggle': [ + value: boolean, + ] }>() defineOptions({ @@ -25,12 +29,12 @@ const isFold = ref(props.fold) watch(() => props.fold, (value) => { isFold.value = value - emit('update:fold', value) + emits('update:fold', value) }) function toggle() { isFold.value = !isFold.value - emit('toggle', isFold.value) + emits('toggle', isFold.value) }