mirror of
https://gitee.com/fantastic-admin/basic.git
synced 2024-12-02 12:07:41 +08:00
refactor: 统一调整 defineEmits
写法
This commit is contained in:
parent
dc625c3c26
commit
6632ffbc65
@ -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)
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -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) : [])
|
||||
},
|
||||
})
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
</script>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user