在### 问题描述
在/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>