欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Vue.js 時(shí)間轉(zhuǎn)換代碼及時(shí)間戳轉(zhuǎn)時(shí)間字符串

 更新時(shí)間:2018年10月16日 11:43:29   作者:tangong0439  
這篇文章主要介紹了Vue.js 時(shí)間轉(zhuǎn)換代碼及時(shí)間戳轉(zhuǎn)時(shí)間字符串,需要的朋友可以參考下

Date.prototype.format = function(format){
 var o = {
 "M+" : this.getMonth()+1, //month
 "d+" : this.getDate(), //day
 "h+" : this.getHours(), //hour
 "m+" : this.getMinutes(), //minute
 "s+" : this.getSeconds(), //second
 "q+" : Math.floor((this.getMonth()+3)/3), //quarter
 "S" : this.getMilliseconds() //millisecond
 }
if(/(y+)/i.test(format)) {
 format = format.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
 }
for(var k in o) {
 if(new RegExp("("+ k +")").test(format)) {
 format = format.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length));
 }
 }
 return format;
 }
//使用方法
var now = new Date();
 var nowStr = now.format("yyyy-MM-dd hh:mm:ss");
 //使用方法2:
 var testDate = new Date();
 var testStr = testDate.format("YYYY年MM月dd日hh小時(shí)mm分ss秒");
alert(testStr);
 //示例:
alert(new Date().format("yyyy年MM月dd日"));
alert(new Date().format("MM/dd/yyyy"));
 alert(new Date().format("yyyyMMdd"));
 alert(new Date().format("yyyy-MM-dd hh:mm:ss"));

代碼:

// 格式化formatter中顯示的時(shí)間格式
// Date.prototype.Format = function(fmt) {
 // const o = {
// 'M+': this.getMonth() + 1, // 月份
// 'd+': this.getDate(), // 日
// 'h+': this.getHours(), // 小時(shí)
// 'm+': this.getMinutes(), // 分
// 's+': this.getSeconds(), // 秒
// 'q+': Math.floor((this.getMonth() + 3) / 3), // 季度
// 'S': this.getMilliseconds(), // 毫秒
// };
 // if (/(y+)/.test(fmt)) { fmt = fmt.replace(RegExp.$1, (`${this.getFullYear()}`).substr(4 - RegExp.$1.length)); }
 // for (const k in o) {
// if (new RegExp(`(${k})`).test(fmt)) { fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : ((`00${o[k]}`).substr((`${o[k]}`).length))); }
// }
// return fmt;
 // };

應(yīng)用:

1、 2018-10-10 轉(zhuǎn) 年月日

// new Date(this.envPlanList[i].starttime.slice(0, 4),
// this.envPlanList[i].starttime.slice(5, 7),
// this.envPlanList[i].starttime.slice(8, 10)),
// new Date(this.envPlanList[i].endtime.slice(0, 4),
// this.envPlanList[i].endtime.slice(5, 7),
// this.envPlanList[i].endtime.slice(8, 10)),

2、 年月日 轉(zhuǎn) 2018-10-10

formatter(params) {
return `${params.name}: ${new Date(params.value[1]).Format('yyyy/MM/dd')} - - ${new Date(params.value[2]).Format('yyyy/MM/dd')} -- ${params.value[3]}`;
// return `${params.name}: ${params.value[1]} -- ${params.value[2]} -- ${params.value[3]}`;
},

下面看下vue.js時(shí)間戳轉(zhuǎn)時(shí)間字符串

formartDate(param) {
 let date = new Date(param);
 Y = date.getFullYear() + '-';
 M = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) + '-' : date.getMonth() + 1 + '-';
 D = date.getDate() < 10 ? '0' + date.getDate() + ' ' : date.getDate() + ' ';
 h = date.getHours() < 10 ? '0' + date.getHours() + ':' : date.getHours() + ':';
 m = date.getMinutes() < 10 ? '0' + date.getMinutes() + ':' : date.getMinutes() + ':';
 s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
 return Y + M + D + h + m + s;
}

總結(jié)

以上所述是小編給大家介紹的Vue.js 時(shí)間轉(zhuǎn)換代碼及時(shí)間戳轉(zhuǎn)時(shí)間字符串,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

  • vue彈窗組件使用方法

    vue彈窗組件使用方法

    彈窗是一個(gè)項(xiàng)目必備的復(fù)用利器,這篇文章主要介紹了vue彈窗組件的使用方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-04-04
  • Vue3中reactive函數(shù)toRef函數(shù)ref函數(shù)簡(jiǎn)介

    Vue3中reactive函數(shù)toRef函數(shù)ref函數(shù)簡(jiǎn)介

    這篇文章主要介紹了Vue3中的三種函數(shù),分別對(duì)reactive函數(shù)toRef函數(shù)以及ref函數(shù)原理及使用作了簡(jiǎn)單介紹,有需要的朋友可以借鑒參考下
    2021-09-09
  • Vue?socket.io模塊實(shí)現(xiàn)聊天室流程詳解

    Vue?socket.io模塊實(shí)現(xiàn)聊天室流程詳解

    vue-socket.io其實(shí)是在socket.io-client(在瀏覽器和服務(wù)器之間實(shí)現(xiàn)實(shí)時(shí)、雙向和基于事件的通信)基礎(chǔ)上做了一層封裝,將socket掛載到vue實(shí)例上,同時(shí)可使用sockets對(duì)象輕松實(shí)現(xiàn)組件化的事件監(jiān)聽,在vue項(xiàng)目中使用起來(lái)更方便
    2022-12-12
  • Vue3中使用Pinia的方法詳細(xì)介紹

    Vue3中使用Pinia的方法詳細(xì)介紹

    這篇文章主要給大家介紹了關(guān)于Vue3中使用Pinia的相關(guān)資料,pinia是一個(gè)用于vue的狀態(tài)管理庫(kù),類似于vuex,是vue的另一種狀態(tài)管理工具,文中介紹的非常詳細(xì),需要的朋友可以參考下
    2024-01-01
  • Vue最新防抖方案(必看篇)

    Vue最新防抖方案(必看篇)

    今天小編就為大家分享一篇Vue最新防抖方案(必看篇),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2019-10-10
  • vue項(xiàng)目接口域名動(dòng)態(tài)獲取操作

    vue項(xiàng)目接口域名動(dòng)態(tài)獲取操作

    這篇文章主要介紹了vue項(xiàng)目接口域名動(dòng)態(tài)獲取操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2020-08-08
  • Vue+axios實(shí)現(xiàn)統(tǒng)一接口管理的方法

    Vue+axios實(shí)現(xiàn)統(tǒng)一接口管理的方法

    這篇文章主要介紹了Vue+axios實(shí)現(xiàn)統(tǒng)一接口管理的方法,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2018-07-07
  • Vite內(nèi)網(wǎng)ip訪問(wèn)2種配置方式

    Vite內(nèi)網(wǎng)ip訪問(wèn)2種配置方式

    這篇文章主要給大家介紹了關(guān)于Vite內(nèi)網(wǎng)ip訪問(wèn)的2種配置方式,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用Vite具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2023-07-07
  • Vue+Typescript中在Vue上掛載axios使用時(shí)報(bào)錯(cuò)問(wèn)題

    Vue+Typescript中在Vue上掛載axios使用時(shí)報(bào)錯(cuò)問(wèn)題

    這篇文章主要介紹了Vue+Typescript中在Vue上掛載axios使用時(shí)報(bào)錯(cuò)問(wèn)題,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值 ,需要的朋友可以參考下
    2019-08-08
  • Vue3?使用Element?Plus表格單選帶checkbox功能

    Vue3?使用Element?Plus表格單選帶checkbox功能

    這篇文章主要介紹了Vue3?使用Element?Plus表格單選帶checkbox,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧
    2023-11-11

最新評(píng)論