12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- let app = new Vue({
- el: '#app',
- data () {
- return {
- time: '',
- }
- },
- beforeMount () {
- },
- mounted () {
- console.log(document.documentElement.scrollWidth,document.documentElement.scrollHeight,'?????????')
- this.time = formatDate()
- this.timer = setInterval(() => {
- this.time = formatDate()
- }, 1000)
- },
- beforeDestroy () {
- if (this.timer) {
- clearInterval(this.timer)
- }
- },
- methods: {
- numFormat (value) {
- if (!value) return '0'
-
- var intPart = parseInt(value)
- var intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,')
- var floatPart = '.00'
- var value2Array = value.toString().split('.')
-
- if (value2Array.length === 2) {
- floatPart = value2Array[1].toString()
- if (floatPart.length === 1) {
-
- return intPartFormat + '.' + floatPart + '0'
- } else {
- return intPartFormat + '.' + floatPart
- }
- } else {
- return intPartFormat
- }
- },
- },
- })
|