Ver código fonte

feat(组件): cropper type 修复callback 类型

gemercheung 2 anos atrás
pai
commit
e5a8eb924b

+ 1 - 1
packages/components/basic/cropper/src/cropper.ts

@@ -9,7 +9,7 @@ export const cropperProps = buildProps({
     },
     img: { type: String },
     cb: {
-        type: Function as PropType<(target?: any, data?: any) => void>,
+        type: Function as PropType<(text?: string, data?: any) => void>,
     },
     showSize: {
         type: Boolean,

+ 4 - 4
packages/components/basic/cropper/src/cropper.vue

@@ -111,9 +111,9 @@ const style = computed(() => ({
 
 const vmRef = ref()
 const on = {
-    imgLoad(status) {
+    imgLoad(status: string) {
         if (status !== 'success') {
-            props.cb('图片加载失败')
+            props.cb && props.cb('图片加载失败')
         }
     },
 }
@@ -124,9 +124,9 @@ const clickHandler = async (status: string) => {
         if (props.showSize) {
             data.push(sizeType.value)
         }
-        props.cb(null, data)
+        props.cb && props.cb('', data)
     } else {
-        props.cb()
+        props.cb && props.cb()
     }
 }
 </script>