vue各種時(shí)間類型轉(zhuǎn)換方法例子
時(shí)間范圍['2024-04-17 14:36:27', '2024-04-24 14:36:27']
console.log(this.$getRecentDays()); 頁面使用默認(rèn)7天 也可以指定console.log(this.$getRecentDays(30));
['2024-04-17 14:36:27', '2024-04-24 14:36:27'] 默認(rèn)值
function getDateString (date, fmt = 'yyyy-MM-dd') { if (/(y+)/.test(fmt)) { fmt = fmt.replace( RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length) ) } let o = { 'M+': date.getMonth() + 1, 'd+': date.getDate(), 'h+': date.getHours(), 'm+': date.getMinutes(), 's+': date.getSeconds(), } for (let k in o) { if (new RegExp(`(${k})`).test(fmt)) { let str = o[k] + '' fmt = fmt.replace( RegExp.$1, RegExp.$1.length === 1 ? str : padLeftZero(str) ) } } return fmt } export function getRecentDays (duration = 7, fmt = 'yyyy-MM-dd hh:mm:ss') { let oneDayLong = 24 * 60 * 60 * 1000 let nowTime = Date.now() let pre7DayTime = nowTime - duration * oneDayLong let now = new Date(nowTime) let pre7Day = new Date(pre7DayTime) return [getDateString(pre7Day, fmt), getDateString(now, fmt)] }
開始時(shí)間結(jié)束時(shí)間['2024-04-17 00:00:00', '2024-04-24 23:59:59']
console.log(this.$todayTimer(30)); 也是可以自定義范圍呢
export function todayTimer (duration = 7, fmt = 'yyyy-MM-dd') { let oneDayLong = 24 * 60 * 60 * 1000 let nowTime = Date.now() let pre7DayTime = nowTime - duration * oneDayLong let now = new Date(nowTime) let pre7Day = new Date(pre7DayTime) return [ getDateString(pre7Day, fmt) + ' ' + '00:00:00', getDateString(now, fmt) + ' ' + '23:59:59', ] }
今年的起始時(shí)間 和結(jié)束時(shí)間 ['2024-01-01 00:00:00', '2024-12-31 23:59:59']
export function todayTimer (duration = 7, fmt = 'yyyy-MM-dd') { let oneDayLong = 24 * 60 * 60 * 1000 let nowTime = Date.now() let pre7DayTime = nowTime - duration * oneDayLong let now = new Date(nowTime) let pre7Day = new Date(pre7DayTime) return [ getDateString(pre7Day, fmt) + ' ' + '00:00:00', getDateString(now, fmt) + ' ' + '23:59:59', ] }
當(dāng)月的開始結(jié)束時(shí)間 ['2024-04-01 00:00:00', '2024-04-30 23:59:59']
export function ofMonth () { const startOfMonth = moment().startOf('month').format('YYYY-MM-DD 00:00:00'); // 本月的起始時(shí)間 const endOfMonth = moment().endOf('month').format('YYYY-MM-DD 23:59:59'); // 本月的結(jié)束時(shí)間 return [startOfMonth, endOfMonth] }
最近幾個(gè)月 ['2023-10-31 00:00:00', '2024-04-30 23:59:59']
最近幾個(gè)月 ['2023-10-31 00:00:00', '2024-04-30 23:59:59']
console.log(this.$recentMonths('month',6));
export function recentMonths (type, val) { const now = moment(); if (type == 'day') { const startDate = now.clone().subtract(val - 1, 'days').startOf('day'); const endDate = now.clone().endOf('day').hours(23).minutes(59).seconds(59); const dayRange = [startDate.format('YYYY-MM-DD HH:mm:ss'), endDate.format('YYYY-MM-DD HH:mm:ss')]; return dayRange; } if (type == 'week') { const weeksAgo = now.clone().subtract(val - 1, 'weeks').startOf('isoWeek'); const thisWeekEnd = now.clone().endOf('week').hours(23).minutes(59).seconds(59); const recentWeeksRange = [weeksAgo.format('YYYY-MM-DD HH:mm:ss'), thisWeekEnd.format('YYYY-MM-DD HH:mm:ss')]; // console.log(recentWeeksRange); return recentWeeksRange; } if (type == 'month') { const sixMonthsAgo = now.clone().subtract(val, 'months').endOf('month').startOf('day'); const thisMonthEnd = now.clone().endOf('month').hours(23).minutes(59).seconds(59); const recentSixMonthsRange = [ sixMonthsAgo.format('YYYY-MM-DD HH:mm:ss'), thisMonthEnd.format('YYYY-MM-DD HH:mm:ss') ] return recentSixMonthsRange } }
各種時(shí)間類型就不一一列了
下面是完整的js代碼
import * as moment from 'moment'; moment.suppressDeprecationWarnings = true; // 封裝的 一些關(guān)于時(shí)間的方法 function random (low, high) { if (arguments.length === 1) { high = low low = 0 } return Math.floor(low + Math.random() * (high - low)) } function randomOne (arr) { return arr[random(arr.length)] } function getDateString (date, fmt = 'yyyy-MM-dd') { if (/(y+)/.test(fmt)) { fmt = fmt.replace( RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length) ) } let o = { 'M+': date.getMonth() + 1, 'd+': date.getDate(), 'h+': date.getHours(), 'm+': date.getMinutes(), 's+': date.getSeconds(), } for (let k in o) { if (new RegExp(`(${k})`).test(fmt)) { let str = o[k] + '' fmt = fmt.replace( RegExp.$1, RegExp.$1.length === 1 ? str : padLeftZero(str) ) } } return fmt } function getDateStringCh (date) { if (!(date instanceof Date)) { return '' } let year = date.getFullYear() let month = date.getMonth() + 1 let day = date.getDate() let hour = date.getHours() return `${year}年${month}月${day}日 ${hour}時(shí)` } function getWeekStartDateAndEndDateRange () { let oneDayLong = 24 * 60 * 60 * 1000 let now = new Date() let mondayTime = now.getTime() - (now.getDay() - 1) * oneDayLong let sundayTime = now.getTime() + (7 - now.getDay()) * oneDayLong let monday = new Date(mondayTime) let sunday = new Date(sundayTime) let weekRange = [getDateString(monday), getDateString(sunday)] return weekRange } // ['2024-04-17 14:36:27', '2024-04-24 14:36:27'] 默認(rèn)值 // console.log(this.$getRecentDays()); 頁面使用 export function getRecentDays (duration = 7, fmt = 'yyyy-MM-dd hh:mm:ss') { let oneDayLong = 24 * 60 * 60 * 1000 let nowTime = Date.now() let pre7DayTime = nowTime - duration * oneDayLong let now = new Date(nowTime) let pre7Day = new Date(pre7DayTime) return [getDateString(pre7Day, fmt), getDateString(now, fmt)] } function getMonthStartDateAndDateRange () { let oneDayLong = 24 * 60 * 60 * 1000 let now = new Date() let year = now.getFullYear() let monthStartDate = new Date(year, now.getMonth(), 1) //當(dāng)前月1號 let nextMonthStartDate = new Date(year, now.getMonth() + 1, 1) //下個(gè)月1號 let days = (nextMonthStartDate.getTime() - monthStartDate.getTime()) / oneDayLong //計(jì)算當(dāng)前月份的天數(shù) let monthEndDate = new Date(year, now.getMonth(), days) let monthRange = [getDateString(monthStartDate), getDateString(monthEndDate)] return monthRange } function padLeftZero (str) { return ('00' + str).substr(str.length) } function resetForm (refName) { this.$refs[refName] && this.$refs[refName].resetFields() } export function debounce (func, wait, immediate) { let timeout, args, context, timestamp, result const later = function () { // 據(jù)上一次觸發(fā)時(shí)間間隔 const last = +new Date() - timestamp // 上次被包裝函數(shù)被調(diào)用時(shí)間間隔 last 小于設(shè)定時(shí)間間隔 wait if (last < wait && last > 0) { timeout = setTimeout(later, wait - last) } else { timeout = null // 如果設(shè)定為immediate===true,因?yàn)殚_始邊界已經(jīng)調(diào)用過了此處無需調(diào)用 if (!immediate) { result = func.apply(context, args) if (!timeout) context = args = null } } } return function (...args) { context = this timestamp = +new Date() const callNow = immediate && !timeout // 如果延時(shí)不存在,重新設(shè)定延時(shí) if (!timeout) timeout = setTimeout(later, wait) if (callNow) { result = func.apply(context, args) context = args = null } return result } } // console.log(this.$randomUUID()); // 1713940662895.5952 數(shù)據(jù)數(shù) function randomUUID () { return Date.now() + Math.random() + '' } const resetTimer = (timer) => { if (timer) { clearTimeout(timer) timer = null } } // ['2024-04-17 00:00:00', '2024-04-24 23:59:59'] 開始時(shí)間結(jié)束時(shí)間 export function todayTimer (duration = 7, fmt = 'yyyy-MM-dd') { let oneDayLong = 24 * 60 * 60 * 1000 let nowTime = Date.now() let pre7DayTime = nowTime - duration * oneDayLong let now = new Date(nowTime) let pre7Day = new Date(pre7DayTime) return [ getDateString(pre7Day, fmt) + ' ' + '00:00:00', getDateString(now, fmt) + ' ' + '23:59:59', ] } // 今年的起始時(shí)間 和結(jié)束時(shí)間 ['2024-01-01 00:00:00', '2024-12-31 23:59:59'] export function ofYear () { const startOfYear = moment().startOf('year').format('YYYY-MM-DD 00:00:00'); const endOfYear = moment().endOf('year').format('YYYY-MM-DD 23:59:59'); return [startOfYear, endOfYear] } // 這個(gè)月的開始結(jié)束時(shí)間 ['2024-04-01 00:00:00', '2024-04-30 23:59:59'] export function ofMonth () { const startOfMonth = moment().startOf('month').format('YYYY-MM-DD 00:00:00'); // 本月的起始時(shí)間 const endOfMonth = moment().endOf('month').format('YYYY-MM-DD 23:59:59'); // 本月的結(jié)束時(shí)間 return [startOfMonth, endOfMonth] } // 上傳json;模板 export function funDownload (content, filename) { // 創(chuàng)建隱藏的可下載鏈接 const eleLink = document.createElement('a') eleLink.download = filename eleLink.style.display = 'none' // 字符內(nèi)容轉(zhuǎn)變成blob地址 let blob = new Blob([content]) eleLink.href = URL.createObjectURL(blob) // 觸發(fā)點(diǎn)擊 document.body.appendChild(eleLink) eleLink.click() // 然后移除 document.body.removeChild(eleLink) } // 對象轉(zhuǎn)json字符串 export function objToJson (obj) { let newObj = {} for (let key in obj) { if (key === 'id') { newObj[key] = obj[key] continue } newObj[key] = JSON.stringify(obj[key]) } return newObj } // 打印 export function print (id) { var bdhtml = window.document.body.innerHTML var jubuData = document.getElementById(id).innerHTML window.document.body.innerHTML = jubuData var style = document.createElement('style'); style.innerHTML = ` @media print { @page { size: auto; margin: 5mm; } body { margin: 0; } .no-print { display: none; } .el-divider { border: 1px solid #dcdfe6; margin: 24px 0; } } `; document.head.appendChild(style); const table = document.querySelectorAll(".el-table__header,.el-table__body,.el-table__footer"); for (let i = 0; i < table.length; i++) { const tableItem = table[i]; tableItem.style.width = '100%'; const child = tableItem.childNodes; for (let j = 0; j < child.length; j++) { const element = child[j]; if (element.localName == 'colgroup') { element.innerHTML = ''; } } } window.print() location.reload() document.head.removeChild(style); window.document.body.innerHTML = bdhtml } // 打印圖片 export function printCanvas (id, i) { var oldstr = document.body.innerHTML // 獲取當(dāng)前頁面內(nèi)容用以還原 var div_print = document.getElementById(id) // 獲取要打印部分的內(nèi)容 var cv = document.getElementsByTagName('canvas')[i] //獲取canvas var resImg = document.getElementById(id) //獲取包裹c(diǎn)anvas的標(biāo)簽 // 將canvas轉(zhuǎn)為圖片 // var context = cv.getContext("2d") var img = new Image() var strDataURI = cv.toDataURL('image/png') img.src = strDataURI // 圖片加載完成之后 img.onload = function () { // 執(zhí)行打印 console.log(img); setTimeout(function () { resImg.innerHTML = `<img src="${strDataURI}">` // 用圖片替代canvas var newstr = div_print.innerHTML document.body.innerHTML = newstr // 將頁面內(nèi)容改為修改后的內(nèi)容 window.print() // 打印 window.location.reload() // 重新加載頁面 document.body.innerHTML = oldstr // 將頁面內(nèi)容還原 }, 1000) } } // 下載echarts為圖片 export function exportpic (chartInstance, name = 'charts') { let picInfo = chartInstance.getDataURL({ type: 'png', pixelRatio: 2, //放大兩倍下載,之后壓縮到同等大小展示。解決生成圖片在移動端模糊問題 backgroundColor: '#fff' });//獲取到的是一串base64信息 const elink = document.createElement('a'); elink.download = name + '.png'; elink.style.display = 'none'; elink.href = picInfo; document.body.appendChild(elink); elink.click(); URL.revokeObjectURL(elink.href); // 釋放URL 對象 document.body.removeChild(elink) } // 復(fù)制 export function copyText (row, column, cell, event) { // 雙擊復(fù)制 let save = function (e) { e.clipboardData.setData('text/plain', event.target.innerText); e.preventDefault(); //阻止默認(rèn)行為 } document.addEventListener('copy', save);//添加一個(gè)copy事件 document.execCommand("copy");//執(zhí)行copy方法 this.$message({ message: '復(fù)制成功', type: 'success' })//提示 } // ['2024-04-23 14:39:48', '2024-04-24 14:39:48'] export function getDefaultTimeRange (type = "real", val, fmt = 'yyyy-MM-dd hh:mm:ss') { let start = new Date() if (type === 'real') { start.setDate(start.getDate() - (val ? val : 1)) } if (type === 'hour') { start.setDate(start.getDate() - (val ? val : 1)) } if (type === 'day') { start.setMonth(start.getMonth() - (val ? val : 1)) } if (type === 'week') { start.setMonth(start.getMonth() - (val ? val : 3)) } if (type === 'month') { start.setFullYear(start.getFullYear() - (val ? val : 1)) } if (type === 'quarter') { val = val || 3; // 如果val未提供,則默認(rèn)為3 start.setFullYear(start.getFullYear() - Math.floor(val / 4)); start.setMonth(start.getMonth() - (val % 4) * 3); } if (type === 'year') { start.setFullYear(start.getFullYear() - (val ? val : 10)) } return [getDateString(start, fmt), getDateString(new Date(), fmt)] } // ['2024-04-24 00:00:00', '2024-04-24 23:59:59'] 一天結(jié)束或開始 export function getDefaultDayRange (type = "real", fmt = 'yyyy-MM-dd hh:mm:ss') { let start = new Date() let end = new Date() if (type === 'real') { start.setDate(start.getDate()) end.setDate(start.getDate()) } if (type === 'hour') { start.setDate(start.getDate()) end.setDate(start.getDate()) } if (type === 'day') { start.setDate(1) end.setMonth(end.getMonth() + 1) end.setDate(0) } if (type === 'month') { start.setDate(1) start.setMonth(0) end.setFullYear(end.getFullYear() + 1) end.setMonth(0) end.setDate(0) } return [getDateString(start, fmt).split(' ')[0] + ' 00:00:00', getDateString(end, fmt).split(' ')[0] + ' 23:59:59'] } // 最近幾個(gè)月 ['2023-10-31 00:00:00', '2024-04-30 23:59:59'] // console.log(this.$recentMonths('month',6)); export function recentMonths (type, val) { const now = moment(); if (type == 'day') { const startDate = now.clone().subtract(val - 1, 'days').startOf('day'); const endDate = now.clone().endOf('day').hours(23).minutes(59).seconds(59); const dayRange = [startDate.format('YYYY-MM-DD HH:mm:ss'), endDate.format('YYYY-MM-DD HH:mm:ss')]; return dayRange; } if (type == 'week') { const weeksAgo = now.clone().subtract(val - 1, 'weeks').startOf('isoWeek'); const thisWeekEnd = now.clone().endOf('week').hours(23).minutes(59).seconds(59); const recentWeeksRange = [weeksAgo.format('YYYY-MM-DD HH:mm:ss'), thisWeekEnd.format('YYYY-MM-DD HH:mm:ss')]; // console.log(recentWeeksRange); return recentWeeksRange; } if (type == 'month') { const sixMonthsAgo = now.clone().subtract(val, 'months').endOf('month').startOf('day'); const thisMonthEnd = now.clone().endOf('month').hours(23).minutes(59).seconds(59); const recentSixMonthsRange = [ sixMonthsAgo.format('YYYY-MM-DD HH:mm:ss'), thisMonthEnd.format('YYYY-MM-DD HH:mm:ss') ] return recentSixMonthsRange } } // 參數(shù)為秒 返回時(shí)間 // console.log(this.$timeRangeFormat(600)); 10分鐘 export function timeRangeFormat (seconds) { const timeUnits = [ { label: '天', value: Math.floor(seconds / (24 * 3600)) }, { label: '小時(shí)', value: Math.floor((seconds % (24 * 3600)) / 3600) }, { label: '分鐘', value: Math.floor((seconds % 3600) / 60) }, { label: '秒', value: Math.floor(seconds % 60) } ] return timeUnits.filter(v => v.value > 0).map(item => `${item.value}${item.label}`).join('').trim() } // {startDateTime: '2023-03-03 00:00:00', endDateTime: '2023-03-03 23:59:59'} // console.log(this.$timeRange('day','2023-03-03')); export function timeRange (type, val) { let startDateTime, endDateTime; switch (type) { case 'hour': startDateTime = moment(val).startOf('hour'); endDateTime = moment(val).endOf('hour'); break; case 'day': startDateTime = moment(val).startOf('day'); endDateTime = moment(val).endOf('day'); break; case 'week': let value = val.toString() const weekYear = value.substring(0, 4) const weekNumber = value.substring(4, 6) startDateTime = moment().isoWeekYear(parseInt(weekYear)).isoWeek(parseInt(weekNumber)).startOf('isoWeek'); endDateTime = moment().isoWeekYear(parseInt(weekYear)).isoWeek(parseInt(weekNumber)).endOf('isoWeek'); break; case 'month': startDateTime = moment(val, "YYYY-MM").startOf('month'); endDateTime = moment(val, "YYYY-MM").endOf('month'); break; case 'quarter': let valSeason = val.toString() const year = valSeason.substring(0, 4) const quarter = valSeason.substring(4, 5) startDateTime = moment().quarter(quarter).year(year).startOf('quarter'); endDateTime = moment().quarter(quarter).year(year).endOf('quarter'); break; case 'year': startDateTime = moment(val, "YYYY").startOf('year'); endDateTime = moment(val, "YYYY").endOf('year'); break; default: return; } startDateTime = startDateTime.format("YYYY-MM-DD HH:mm:ss"); endDateTime = endDateTime.format("YYYY-MM-DD HH:mm:ss"); return { startDateTime, endDateTime }; } export function timeFormatting (type, val) { if (type == 'hour') { let hour = moment().set({ hour: val, minute: 0, second: 0, millisecond: 0 }).format('YYYY-MM-DD HH'); return hour } else if (type == 'day') { let day = moment().date(val).format('YYYY-MM-DD'); return day } else if (type == 'month') { let month = moment(val, 'MM').format('YYYY-MM'); return month } } // console.log(this.$timeFormatType('day', '2023123')); 2023-12-03 export function timeFormatType (type, val) { if (type == 'hour') { let [year, month, date, hour] = String(val).split(/(\d{4})(\d{2})(\d{2})(\d{2})/).slice(1); // 創(chuàng)建moment對象并設(shè)置時(shí)間 let momentDate = moment().set({ year: parseInt(year), month: parseInt(month) - 1, date: parseInt(date), hour: parseInt(hour), minute: 0, second: 0, millisecond: 0 }); // 格式化時(shí)間 let hourVal = momentDate.format('YYYY-MM-DD HH'); return hourVal } else if (type == 'day') { let day = moment(val, 'YYYYMMDD').format('YYYY-MM-DD'); return day } else if (type == 'month') { const month = moment(val, 'YYYYMM').format('YYYY-MM'); return month } else if (type == 'year') { const year = moment(val, 'YYYY').format('YYYY'); return year } else if (type == 'week') { const weekYear = val.toString().substring(0, 4); const weekNum = val.toString().substring(4); const startDate = moment(`${weekYear}-01-01`).add((weekNum) * 7, 'days').startOf('isoWeek'); let week = startDate.format('YYYY-WW'); return week } else if (type == 'quarter') { const quarterYear = val.toString().substring(0, 4); const quarterNum = val.toString().substring(4); // 計(jì)算季度的第一天日期 const startDate = moment(`${quarterYear}-01-01`).add((quarterNum - 1) * 3, 'months').startOf('month'); let quarter = startDate.format('YYYY-Q'); return quarter } } // console.log(this.$tenMonthsAgo(24, 'month')); // ['2022-04', '2024-04'] export function tenMonthsAgo (val, type) { if (type == 'hour') { return hour } else if (type == 'day') { return day } else if (type == 'month') { const tenMonthsAgo = moment().subtract(val, 'months').format('YYYY-MM'); const currentMonth = moment().format('YYYY-MM'); const month = [tenMonthsAgo, currentMonth]; return month } } export function tenMonthsHistory (val, type) { if (type == 'hour') { return hour } else if (type == 'day') { return day } else if (type == 'month') { const tenMonthsAgo = moment().subtract(val, 'months').format('YYYY-MM'); const currentMonth = moment().subtract(1, 'months').format('YYYY-MM'); const month = [tenMonthsAgo, currentMonth]; return month } } // 20240101 console.log(this.$timeTypeFormatting('day', '2024-01-01'),); export function timeTypeFormatting (type, value) { switch (type) { case 'hour': return value.substring(0, 13).replace(/[- :]/g, ""); break; case 'day': return value.replace(/[- :]/g, ""); break; case 'week': return (moment(value).isoWeekYear() + ' ' + moment(value).isoWeek()).replace(/[- :]/g, ""); break; case 'month': return value.replace(/[- :]/g, ""); break; case 'year': return value.replace(/[- :]/g, ""); break; default: ''; } } export function getBase64 (file) { return new Promise(function (resolve, reject) { const reader = new FileReader() let imgResult = '' reader.readAsDataURL(file) reader.onload = function () { imgResult = reader.result } reader.onerror = function (error) { reject(error) } reader.onloadend = function () { resolve(imgResult) } }) } export function getEmpty (val) { if (val !== null && val !== false && val !== undefined && val !== NaN && val !== '') { return val } else { return '-' } } export function getEmptyUnit (val, unit) { if (val !== null && val !== false && val !== undefined && val !== NaN && val !== '' && val != '0.00' && val !== 0 && val && val !== 'NaN') { return unit } else { return '' } } export function findObjectByValue (arr, val) { let result = []; function search (arr, parentObjects = []) { for (let i = 0; i < arr.length; i++) { if (arr[i].id === val) { // 找到匹配項(xiàng),將當(dāng)前對象和所有父級對象都添加到結(jié)果數(shù)組 result.push(...parentObjects, arr[i]); } if (arr[i].childs && arr[i].childs.length > 0) { // 遞歸搜索子對象,將當(dāng)前對象添加到父級對象數(shù)組中 search(arr[i].childs, [...parentObjects, arr[i]]); } } } search(arr); return result; } export default { install (vue) { this.addGlobalMethods(vue) }, addGlobalMethods (vue) { vue.prototype.$random = random vue.prototype.$resetForm = resetForm vue.prototype.$randomOne = randomOne vue.prototype.$getDateString = getDateString vue.prototype.$getRecentDays = getRecentDays vue.prototype.$getWeekStartDateAndEndDateRange = getWeekStartDateAndEndDateRange vue.prototype.$getMonthStartDateAndDateRange = getMonthStartDateAndDateRange vue.prototype.$debounce = debounce vue.prototype.$getDateStringCh = getDateStringCh vue.prototype.$randomUUID = randomUUID vue.prototype.$resetTimer = resetTimer vue.prototype.$todayTimer = todayTimer vue.prototype.$funDownload = funDownload vue.prototype.$objToJson = objToJson vue.prototype.$print = print vue.prototype.$printCanvas = printCanvas vue.prototype.$exportpic = exportpic vue.prototype.$copyText = copyText vue.prototype.$getDefaultTimeRange = getDefaultTimeRange vue.prototype.$timeRangeFormat = timeRangeFormat vue.prototype.$timeRange = timeRange vue.prototype.$ofYear = ofYear vue.prototype.$ofMonth = ofMonth vue.prototype.$getDefaultDayRange = getDefaultDayRange vue.prototype.$timeFormatting = timeFormatting vue.prototype.$getBase64 = getBase64 vue.prototype.$getEmpty = getEmpty vue.prototype.$getEmptyUnit = getEmptyUnit vue.prototype.$findObjectByValue = findObjectByValue vue.prototype.$tenMonthsAgo = tenMonthsAgo vue.prototype.$timeTypeFormatting = timeTypeFormatting vue.prototype.$timeFormatType = timeFormatType vue.prototype.$tenMonthsHistory = tenMonthsHistory vue.prototype.$recentMonths = recentMonths }, }
總結(jié)
到此這篇關(guān)于vue各種時(shí)間類型轉(zhuǎn)換的文章就介紹到這了,更多相關(guān)vue時(shí)間類型轉(zhuǎn)換內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
nuxt.js服務(wù)端渲染中axios和proxy代理的配置操作
這篇文章主要介紹了nuxt.js服務(wù)端渲染中axios和proxy代理的配置操作,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-11-11vue-router后臺鑒權(quán)流程實(shí)現(xiàn)
本文主要介紹了vue-router后臺鑒權(quán)流程實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2022-08-08Vue render渲染時(shí)間戳轉(zhuǎn)時(shí)間,時(shí)間轉(zhuǎn)時(shí)間戳及渲染進(jìn)度條效果
這篇文章主要介紹了Vue render渲染時(shí)間戳轉(zhuǎn)時(shí)間,時(shí)間轉(zhuǎn)時(shí)間戳及渲染進(jìn)度條效果,通過實(shí)例代碼相結(jié)合的形式給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2018-07-07關(guān)于nuxt?store中保存localstorage的問題
這篇文章主要介紹了關(guān)于nuxt?store中保存localstorage的問題,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2023-10-10