I'm coding Nuxt 3 and having the following bug
my function,
const checkFileSize = (file: File): boolean => {
if (!file) {
return true;
}
return props.maxSize * 1024 * 1024 >= file.size;
};
This function is call when I upload a file.
but when I console log the above file it returns a Proxy object and because of that I can not read file.size . The file.size return undefined
I fixed it into file.value.size and it worked but the type error on the function input is wrong (because interface File does not have any value key)
So do I have to change the type (In this case File => what?).
Or do I have to call my function somewhere else to get the exactly file: File input
I fixed it into file.value.size and it worked but the type error on the function input is wrong (Cuz interface File does not have any value key)
*Updated:
Currently I use this code to call handleChange function, and inside handleChange I call checkFileSize
const handleChange = (file: File) => {
checkFileSize(file)
}
<v-file-input @change="handleChange" />
Still the problem of define a type for ref value
ref<File>Filethen you could pass ref value to it and not a ref itself.