vue-filters.js 463 B

123456789101112131415161718
  1. import { dateFormat as formatDate } from '@/utils'
  2. import Vue from 'vue'
  3. // 日期格式化
  4. const dateFormat = (value) => {
  5. return formatDate(new Date(value), 'yyyy-MM-dd')
  6. }
  7. const fileSize = (size) => {
  8. size = Math.round(size / 1024)
  9. if (size < 1024) return size + 'KB'
  10. size = Math.round(size / 1024)
  11. if (size < 1024) return size + 'MB'
  12. return Math.round(size / 1024) + 'GB'
  13. }
  14. Vue.filter('dateFormat', dateFormat)
  15. Vue.filter('fileSize', fileSize)