time.js

export const formatDateTime = () => {
    let date = new Date();
    let timeStr = date.getFullYear() + '-';
    timeStr += date.getMonth() + 1 + '-';
    timeStr += date.getDate();
    return timeStr;
}

页面中使用

import { formatDateTime } from './time'

mounted() {
  console.log('当前时间:'+ formatDateTime(new Date().getTime()))     
}  
Logo

前往低代码交流专区

更多推荐