iview组件触发的事件调用tools中方法的问题

在### 问题描述
在/src/libs/tools.js 中定义了 judgeFileType 方法
在Upload组件的before-upload事件中调用了 judgeFileType 方法

报错:
Property or method "judgeFileType" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.

问题出现的环境背景及自己尝试过哪些方法

1、直接调用 judgeFileType 会报错
2、在 judgeFileType 外层包一层 plugappBeforeUpload 函数,执行会正确运行
3、把tools中的 judgeFileType 移到vue组件中能正常运行

相关代码

<Upload :before-upload="file=> judgeFileType(file,'crx')"> //报错
<Upload :before-upload="file=> plugappBeforeUpload(file,'crx')"> //正确运行

<script>
import { judgeFileType } from 'src/libs/tools'

plugappBeforeUpload (file, type) {
    return judgeFileType(file, type)
}
</script>

请大佬赐教为什么会报错,有更好的处理方法嘛?

阅读 1k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题