Blame view

src/utils/formatNum.js 740 Bytes
9a83dd61   liuqimichale   全局注册util方法
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  // export function formatNum(str) {
  //   var newStr = "";
  //   var count = 0;
  //   for (var i = str.length - 1; i >= 0; i--) {
  //     if (count % 3 == 0 && count != 0) {
  //
  //       newStr = str.charAt(i) + "," + newStr;
  //     } else {
  //       newStr = str.charAt(i) + newStr;
  //     }
  //     count++;
  //   }
  //   str = newStr;
  //   return str;
  //
  // }
  
  function formatNumArr(str) {
    console.log(typeof str)
841f35d2   liuqimichale   filter
20
21
22
23
24
25
26
27
28
29
30
31
    var newStr = "";
    var count = 0;
    for (var i = str.length - 1; i >= 0; i--) {
      if (count % 3 == 0 && count != 0) {
  
        newStr = str.charAt(i) + "," + newStr;
      } else {
        newStr = str.charAt(i) + newStr;
      }
      count++;
    }
    str = newStr;
9a83dd61   liuqimichale   全局注册util方法
32
    str = str.split('')
841f35d2   liuqimichale   filter
33
34
35
    return str;
  
  }
9a83dd61   liuqimichale   全局注册util方法
36
37
  
  export default {formatNumArr}