Vue获取当前时间( 年初-年末、月初-月末、)

news/2024/7/10 1:57:36 标签: javascript, vue
javascript">     // 获取年初-年末、月初-月末、
      getNowTime() {
        var now = new Date();
        var year = now.getFullYear(); //得到年份
        var month = now.getMonth(); //得到月份
        var day = now.getDate(); //得到天
        if (day < 10) {
          day = "0" + day
        }
        month = month + 1;
        month = month.toString().padStart(2, "0");
        var defaultDate = `${year}-${month}`;
        this.value1 = defaultDate;
        this.value2 = defaultDate;
        this.value3 = defaultDate;
        this.value4 = defaultDate;
        this.value6 = defaultDate;
        this.today.date_from = `${year}-${month}-${day}`
        this.today.date_to = `${year}-${month}-${day}`
        this.month.date_from = `${year}-${month}-01`
        this.month.date_to = `${year}-${month}-31`
        this.year.date_from = `${year}-01-01`
        this.year.date_to = `${year}-12-31`

        console.log(this.today.date_from + '-today.date_from')
        console.log(this.today.date_to + '-today.date_to')
        console.log(this.month.date_from + '-month.date_from')
        console.log(this.month.date_to + '-month.date_to')
        console.log(this.year.date_from + '-year.date_from')
        console.log(this.year.date_to + '-year.date_to')

        // 对象不要直接赋值,其中涉及深浅拷贝原理
        switch (this.top_value) {
          case 1:
            this.date = JSON.parse(JSON.stringify(this.today));
            break;
          case 2:
            this.date = JSON.parse(JSON.stringify(this.month));
            break;
          case 3:
            this.date = JSON.parse(JSON.stringify(this.year));
            break;
          case 4:
            this.date.date_from = null;
            this.date.date_to = null
            break;

          default:
            break;
        }
      },

在这里插入图片描述


http://www.niftyadmin.cn/n/1410140.html

相关文章

第 94 章 NET SNMP (Simple Network Management Protocol)

94.1. 安装SNMP 94.1.1. Ubuntu search package netkillerneo:~$ apt-cache search snmp libsnmp-base - NET SNMP (Simple Network Management Protocol) MIBs and Docs libsnmp-perl - NET SNMP (Simple Network Management Protocol) Perl5 Support libsnmp-session-perl - …

python beautifulsoup多线程分析抓取网页

python beautifulsoup多线程分析抓取网页最近在用python做一些网页分析方面的事情&#xff0c;很久没更新博客了&#xff0c;今天补上。下面的代码用到了 1 python 多线程 2 网页分析库&#xff1a;beautifulsoup ,这个库比之前分享的python SGMLParser 网页分析库要强大很多&a…

python set

1先看下python 集合类型的不重复性&#xff0c;这方面做一些去重处理非常的好&#xff0c;比如我们要处理一些数据&#xff0c;想把重复的数据给去掉&#xff0c;然后在操作的话&#xff0c;可以把它转换成集合类型&#xff0c;然后在由集合类型转换成其他的类型。a [2,3,4,2,…

halcon算子翻译——set_framegrabber_lut

名称 set_framegrabber_lut - 设置图像采集设备的查找表。 用法 set_framegrabber_lut( : : AcqHandle, ImageRed, ImageGreen, ImageBlue : ) 描述 算子set_framegrabber_lut设置由AcqHandle指定的图像采集设备的查找表&#xff08;LUT&#xff09;。 请注意&#xff0c;此算子…

Vue 搜索框 延时请求接口

watch: {/*** description 自动化filter数据变化*/filter: {handler(newValue, oldValue) {clearTimeout(this.timer); //清除延迟执行this.timer setTimeout(() > { //设置延迟执行console.log(search: newValue , oldValue);this.dataPagination.currentPage 0;this.…

EM算法是炼金术吗?

人工智能很火&#xff0c;人工智能大神很火。大神们的神器是什么&#xff1f;有人说找到了&#xff0c;就是EM算法。 请看这篇&#xff1a; EM算法的九层境界&#xff1a;Hinton和Jordan理解的EM算法 但是最近网上引人关注的另一传闻是&#xff0c;一位人工智能论文获奖者在获奖…

Vue插件视频播放插件

Player视频播放 安装插件 npm install vue-video-player --save引用插件 //1、全局引用 import VideoPlayer from "vue-video-player"; import vue-video-player/src/custom-theme.css // 视频插件样式 import video.js/dist/video-js.css // 视频插件样式 Vue.us…

Vue全局前置守卫

// 全局前置守卫 router.beforeEach((to, from, next) > {console.log(to)console.log(from)// to:即将要进入的目标 路由对象// from: 当前导航正要离开的路由// next: // console.log(to, from, next)new Common({title: to.meta.title,})// if (to.path /login) {// s…