investHomeBig.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. let app = new Vue({
  2. el: '#app',
  3. data () {
  4. return {
  5. time: '',
  6. }
  7. },
  8. beforeMount () {
  9. },
  10. mounted () {
  11. console.log(document.documentElement.scrollWidth,document.documentElement.scrollHeight,'?????????')
  12. this.time = formatDate()
  13. this.timer = setInterval(() => {
  14. this.time = formatDate()
  15. }, 1000)
  16. },
  17. beforeDestroy () {
  18. if (this.timer) {
  19. clearInterval(this.timer)
  20. }
  21. },
  22. methods: {
  23. numFormat (value) {
  24. if (!value) return '0'
  25. // var intPart = Number(value).toFixed(0) // 获取整数部分
  26. var intPart = parseInt(value)// 获取整数部分
  27. var intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') // 将整数部分逢三一断
  28. var floatPart = '.00' // 预定义小数部分
  29. var value2Array = value.toString().split('.')
  30. // =2表示数据有小数位
  31. if (value2Array.length === 2) {
  32. floatPart = value2Array[1].toString() // 拿到小数部分
  33. if (floatPart.length === 1) {
  34. // 补0
  35. return intPartFormat + '.' + floatPart + '0'
  36. } else {
  37. return intPartFormat + '.' + floatPart
  38. }
  39. } else {
  40. return intPartFormat
  41. }
  42. },
  43. },
  44. })