You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

30 lines
773 B

  1. import Vue from "vue";
  2. import * as dayjs from "dayjs";
  3. Vue.filter('NumberFormat', function (value) {
  4. if (!value) {
  5. return '0'
  6. }
  7. let intPartFormat = value.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') //将整数部分逢三一断
  8. return intPartFormat
  9. })
  10. Vue.filter('dayjs', function(dataStr, pattern = 'YYYY-MM-DD HH:mm:ss') {
  11. return dayjs(dataStr).format(pattern)
  12. })
  13. Vue.filter('moment', function(dataStr, pattern = 'YYYY-MM-DD HH:mm:ss') {
  14. return dayjs(dataStr).format(pattern)
  15. })
  16. /** 字符串超长截取省略号显示 */
  17. Vue.filter('ellipsis', function (value, vlength = 25) {
  18. if(!value){
  19. return "";
  20. }
  21. console.log('vlength: '+ vlength);
  22. if (value.length > vlength) {
  23. return value.slice(0, vlength) + '...'
  24. }
  25. return value
  26. })