Open dmitry-saritasa opened 6 years ago
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
Thank you!
@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.
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 - 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 What does the errors in the console say?
You have to include this filter by yourself.
Thank you for your wonderful work on vue-upload-component!
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?