vue-upload-component icon indicating copy to clipboard operation
vue-upload-component copied to clipboard

[Vue warn]: Failed to resolve filter: formatSize

Open dmitry-saritasa opened this issue 7 years ago • 7 comments

Thank you for your wonderful work on vue-upload-component!

<td>{{ file.size | formatSize }}</td>

Are you using some 3rd party library for such filters? I don't see such filter implementation in the lian-yue/vue-upload-component repository.

Am I missing something?

dmitry-saritasa avatar Mar 01 '18 02:03 dmitry-saritasa

Vue.filter('formatSize', function (size) {
  if (size > 1024 * 1024 * 1024 * 1024) {
    return (size / 1024 / 1024 / 1024 / 1024).toFixed(2) + ' TB'
  } else if (size > 1024 * 1024 * 1024) {
    return (size / 1024 / 1024 / 1024).toFixed(2) + ' GB'
  } else if (size > 1024 * 1024) {
    return (size / 1024 / 1024).toFixed(2) + ' MB'
  } else if (size > 1024) {
    return (size / 1024).toFixed(2) + ' KB'
  }
  return size.toString() + ' B'
})

https://github.com/lian-yue/vue-upload-component/blob/master/docs/index.js#L112

lian-yue avatar Mar 01 '18 06:03 lian-yue

Thank you!

osserpse avatar Jun 28 '18 14:06 osserpse

@osserpse - did you get it working? I can see the implementation in index.js but I am not able to get it working? Is there any extra step which is required.

gopalkb avatar Oct 16 '19 09:10 gopalkb

Hello @gopalkb My index.js is identical regarding the formatSize filter. Then (of course) I've added this where I want to output formatSize:

<span> ({{file.size | formatSize}})</span>

What is going wrong for you?

osserpse avatar Oct 16 '19 19:10 osserpse

@osserpse - I also have the same index.js and I have used formatSize in my component the way you've mentioned. It is still showing the error in console. So, I am not sure if I have to do some extra import in my component though I have the vue-upload-component already imported in my component.

gopalkb avatar Oct 18 '19 07:10 gopalkb

@gopalkb What does the errors in the console say?

osserpse avatar Oct 18 '19 07:10 osserpse

You have to include this filter by yourself.

outOFFspace avatar Feb 11 '20 07:02 outOFFspace