IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> JavaScript知识库 -> vue中获取当前时间并格式化处理 -> 正文阅读

[JavaScript知识库]vue中获取当前时间并格式化处理

day.js 封装公共js文件

/// <reference path="./locale/index.d.ts" />
export = dayjs;
declare function dayjs (date?: dayjs.ConfigType, option?: dayjs.OptionType, locale?: string): dayjs.Dayjs
declare namespace dayjs {
  export type ConfigType = string | number | Date | Dayjs
  export type OptionType = { locale?: string, format?: string, utc?: boolean } | string
  type UnitTypeShort = 'd' | 'M' | 'y' | 'h' | 'm' | 's' | 'ms'
  export type UnitType = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'month' | 'year' | 'date' | UnitTypeShort;
  export type OpUnitType = UnitType | "week" | 'w';
  export type QUnitType = UnitType | "quarter" | 'Q';
  class Dayjs {
    constructor (config?: ConfigType)
    clone(): Dayjs
    isValid(): boolean
    year(): number
    year(value: number): Dayjs
    month(): number
    month(value: number): Dayjs
    date(): number
    date(value: number): Dayjs
    day(): number
    day(value: number): Dayjs
    hour(): number
    hour(value: number): Dayjs
    minute(): number
    minute(value: number): Dayjs
    second(): number
    second(value: number): Dayjs
    millisecond(): number
    millisecond(value: number): Dayjs
    set(unit: UnitType, value: number): Dayjs
    get(unit: UnitType): number
    add(value: number, unit: OpUnitType): Dayjs
    subtract(value: number, unit: OpUnitType): Dayjs
    startOf(unit: OpUnitType): Dayjs
    endOf(unit: OpUnitType): Dayjs
    format(template?: string): string
    diff(date: ConfigType, unit?: QUnitType | OpUnitType, float?: boolean): number
    valueOf(): number
    unix(): number
    daysInMonth(): number
    toDate(): Date
    toJSON(): string
    toISOString(): string
   toString(): string
    utcOffset(): number
    isBefore(date: ConfigType, unit?: OpUnitType): boolean
    isSame(date: ConfigType, unit?: OpUnitType): boolean
    isAfter(date: ConfigType, unit?: OpUnitType): boolean
    locale(): string
    locale(preset: string | ILocale, object?: Partial<ILocale>): Dayjs
  }
  export type PluginFunc = (option: any, c: typeof Dayjs, d: typeof dayjs) => void
  export function extend(plugin: PluginFunc, option?: any): Dayjs
  export function locale(preset: string | ILocale, object?: Partial<ILocale>, isLocal?: boolean): string
  export function isDayjs(d: any): d is Dayjs
  export function unix(t: number): Dayjs
  const Ls : { [key: string] :  ILocale }
}

vue页面使用

// 获取当前时间并且时间格式化成  'YYYY-MM-DD'
  let nowTime = dayjs(new Date().toLocaleDateString()).format('YYYY-MM-DD')
  JavaScript知识库 最新文章
ES6的相关知识点
react 函数式组件 & react其他一些总结
Vue基础超详细
前端JS也可以连点成线(Vue中运用 AntVG6)
Vue事件处理的基本使用
Vue后台项目的记录 (一)
前后端分离vue跨域,devServer配置proxy代理
TypeScript
初识vuex
vue项目安装包指令收集
上一篇文章      下一篇文章      查看所有文章
加:2021-07-22 14:04:22  更:2021-07-22 14:06:09 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2025年4日历 -2025/4/22 8:04:06-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码