0
Follow
0
View

el-date-picker How do I get this week's date

sggstz 注册会员
2023-02-28 13:20
< div class = "md_content_show e397 data - v - 3967" = "" >

perfect

dc200687 注册会员
2023-02-28 13:20

Based on Monster group and GPT write:

<template>
  <el-date-picker
    v-model="dateRange"
    type="week"
    start-placeholder="开始日期"
    end-placeholder="结束日期"
    @change="handleChange"
  >
  el-date-picker>
template>

<script>
export default {
  data() {
    return {
      dateRange: [],
    };
  },
  methods: {
    handleChange(value) {
      const [start, end] = value.split(" - ");
      console.log(start, end); // 输出本周的起始日期和结束日期
    },
  },
};
script>

The type attribute is set to week, indicating that the week is selected. When the user selects a week, the value argument will be a string containing the start and end dates of the week. In the handleChange method, we can split the string into a start date and an end date and print them to the console.

cxy2268 注册会员
2023-02-28 13:20

     const date = new Date();
         const end = new Date();
         const week = new Date().getDay();
         const start = new Date();
         start.setTime(date.getTime() - 3600 * 1000 * 24 * (week==0 ? 6:week - 1));
         end.setTime(date.getTime() + 3600 * 1000 * 24 * (7 - (week==0 ? 7:week)));
 picker.$emit('pick', [start, end]);
.
< !- - - - - >

About the Author

Question Info

Publish Time
2023-02-28 13:20
Update Time
2023-02-28 13:20

Related Question

为什么我的第二个do循环结果只有一个数啊

Tagetik系统中科目维度里的FST是啥?

为什么这里要有个double啊

OpenCV,imshow函数,程序没有报错,但是图片窗口未弹出,如何解决?

Laravel +惯性+ Vue基本设置错误:找不到模块'./Event/Show'

vivado 仿真报错

如何完全静态编译Qt Widgets项目?

cordova ionic项目包装名称问题

如何增加上传docx文件到服务器的选项

制作页面并专注于它们,就像react中的word doc一样