Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【欢迎认领】uploadfile组件调用出错 #61

Open
javachens opened this issue Jun 21, 2024 · 1 comment
Open

【欢迎认领】uploadfile组件调用出错 #61

javachens opened this issue Jun 21, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@javachens
Copy link

在crm模块中使用到文件上传的均出错如下,而且该组件在表单中使用时候为自动上传且清掉filelist,如果此时想删除时则无法操作,上传文件市错误如下,原因好像是得不到绑定值modelValue
chunk-ZM53WNRW.js?v=41a044d2:1784 [Vue warn]: Unhandled error during execution of scheduler flush. This is likely a Vue internals bug. Please open an issue at https://github.com/vuejs/core .
at <UploadFile modelValue=
(2) [undefined, undefined]
onUpdate:modelValue=fn class="min-w-80px" >
at
at
at
at <ElForm ref="formRef" model=
{bizType: 1, bizId: '9', picUrls: Array(0), fileUrls: Array(2)}
rules=
{type: Array(1), content: Array(1), nextTime: Array(1)}
... >
at <ElDialogContent key=0 ref_key="dialogContentRef" ref=Ref<
Proxy(Object) {…}

... >
at <ElFocusTrap loop="" trapped=true focus-start-el="container" ... >
at <ElOverlay custom-mask-event="" mask=true overlay-class=undefined ... >
at <BaseTransition onAfterEnter=fn onAfterLeave=fn onBeforeLeave=fn ... >
at <Transition name="dialog-fade" onAfterEnter=fn onAfterLeave=fn ... >
at <ElDialog onUpdate:modelValue=fn modelValue=true width="50%" ... >
at <Dialog modelValue=true onUpdate:modelValue=fn title="新增" ... >
at <FollowUpRecordForm ref="formRef" onSuccess=fn >
at
at
at
at
at <CrmClueDetail onVnodeUnmounted=fn ref=Ref<
Proxy(Object) {__v_skip: true}
key="/crm/clue/detail/9" >
at <KeepAlive include=
['Index']

at
at
at
at <Layout class="" onVnodeUnmounted=fn ref=Ref<
Proxy(Object) {…}

at
at <ElConfigProvider namespace="el" locale=
{name: 'zh-cn', el: {…}}
message=
{max: 1}
... >
at
at
UploadFile.vue:158 Uncaught (in promise)
TypeError: Cannot read properties of undefined (reading 'substring')
at UploadFile.vue:158:20
at Proxy.map ()
at watch.immediate (UploadFile.vue:158:20)
at callWithErrorHandling (chunk-ZM53WNRW.js?v=41a044d2:1868:19)
at callWithAsyncErrorHandling (chunk-ZM53WNRW.js?v=41a044d2:1875:17)
at job (chunk-ZM53WNRW.js?v=41a044d2:3444:9)
at flushPreFlushCbs (chunk-ZM53WNRW.js?v=41a044d2:2010:7)
at updateComponentPreRender (chunk-ZM53WNRW.js?v=41a044d2:6974:5)
at ReactiveEffect.componentUpdateFn [as fn] (chunk-ZM53WNRW.js?v=41a044d2:6887:11)
at ReactiveEffect.run (chunk-ZM53WNRW.js?v=41a044d2:1410:23)

错误处代码为
// 监听模型绑定值变动
watch(
() => props.modelValue,
(val: string | string[]) => {
console.log(val)
if (!val) {
fileList.value = [] // fix:处理掉缓存,表单重置后上传组件的内容并没有重置
return
}

fileList.value = [] // 保障数据为空
// 情况1:字符串
if (isString(val)) {
  fileList.value.push(
    ...val.split(',').map((url) => ({ name: url.substring(url.lastIndexOf('/') + 1), url }))
  )
  return
}
// 情况2:数组
fileList.value.push(
  ...(val as string[]).map((url) => ({ name: url.substring(url.lastIndexOf('/') + 1), url }))
)

},
{ immediate: true, deep: true }
)

@YunaiV YunaiV added the bug Something isn't working label Jun 22, 2024
@YunaiV YunaiV changed the title uploadfile组件调用出错 【欢迎认领】uploadfile组件调用出错 Jun 22, 2024
@YunaiV
Copy link
Contributor

YunaiV commented Jun 22, 2024

有兴趣 pull request 尝试修复下么?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants