当前位置: 首页 > news >正文

wordpress 主题 mnews武汉seo论坛

wordpress 主题 mnews,武汉seo论坛,贵州建设厅网站建筑企业公示栏,做网站租服务器吗背景: 使用elenmet plus 组件实现时间选择;且日期时间选择不能超过今天;连续选中时间的长度范围不能超过7天 效果展示: 实现思路: 一、使用element组件自带的属性和方法; :disabled-date"disabledDate…

背景:

使用elenmet plus 组件实现时间选择;且日期时间选择不能超过今天;连续选中时间的长度范围不能超过7天

效果展示:

 

 

实现思路:

一、使用element组件自带的属性和方法;

:disabled-date="disabledDate"

@calendar-change="calendarChange"

@blur="handleBlur" 

二、使用js方法判断,通过时间组件选择的时间范围value值是否符合条件。

一、element日期时间组价

布局代码:

//布局代码
<el-date-picker v-model="data.valueTwoTimer" type="datetimerange"value-format="YYYY-MM-DD HH:mm:ss" range-separator="至" start-placeholder="开始时间"end-placeholder="结束时间" :unlink-panels="true" :default-time="data.valueTwoTimer":disabled-date="disabledDate" @calendar-change="calendarChange"     @blur="handleBlur" 
/>

核心属性和方法:

:disabled-date="disabledDate" @calendar-change="calendarChange" @blur="handleBlur" 

//vue3的写法
<script setup>
import { onMounted, reactive } from "vue";
const calendarChange = (dates) => {let hasSelectDate = dates !== null && dates.length > 0;data.minTime = hasSelectDate ? dates[0] : null;
};
const disabledDate = (time) => {const timeRange = 1 * 24 * 60 * 60 * 1000; // 1天时间戳const tempTime = Date.now() - timeRange;//是否触发calendarChange() if (data.minTime) {const minTime = new Date(data.minTime).getTime();const maxTime = new Date(data.minTime).getTime() + timeRange * 6;// 最大选择7天时间if (tempTime < maxTime) {return time.getTime() < minTime || time.getTime() > tempTime;}return time.getTime() < minTime || time.getTime() > maxTime;} else {return time.getTime() >= tempTime;//不能超过今天}
};
const handleBlur = () => {data.minTime = null;
};
</script>

二、自定义的js方法判断 

自定义一个判断最大选择7天时间的方法。调取接口时触发此方法、或者时间选择完毕后触发此方法等。

//最大7天
const timeLimite = () => {const minTime = timeToTimestamp(times[0]);const maxTime = timeToTimestamp(times[1]);const isOver7 = maxTime - minTime > timeRange * 7;if (isOver7) {ElMessage({type: "warning",message: `历史记录查询时间不能超过7天`,});return false;}
}
const timeRange = 1 * 24 * 60 * 60 * 1000; // 1天时间戳
const timeToTimestamp = (time) => {let timestamp = Date.parse(new Date(time).toString());return timestamp;
};

 

http://www.15wanjia.com/news/39441.html

相关文章:

  • 哪些网站做的好处和坏处长沙seo优化排名
  • 上海公安门户网站交换友情链接的平台有哪些
  • 网站首屏做多大推广普通话内容50字
  • 石家庄工程信息网百度优化排名
  • 目录搜索引擎网站网站排名靠前
  • wordpress 轻博客主题郑州粒米seo外包
  • 怎么做签到网站公司网络组建方案
  • 陈巴尔虎旗网站建设太原seo网站管理
  • 磐安建设局网站北京疫情最新情况
  • 推广团队在哪里找沈阳关键词优化报价
  • 图片网站cms网络营销的种类有哪些
  • 网站制作内容文案免费代码网站
  • 机加工网站百度官网首页登陆
  • 网站建设纳入本单位日常性工作企业培训课程价格
  • python做网站挣钱竞价推广账户托管
  • 城市网站联盟建网站需要什么
  • 网站上线前做环境部署数据分析师一般一个月多少钱
  • 音乐网站开发结语营销管理培训课程
  • 互利互通网站建设营销方案模板
  • 天津工程建设信息网站google官方下载app
  • 做编程的 网站希爱力的功效及副作用
  • 企业网站建设熊掌号企业网站的基本功能
  • 网站信息设计搜索引擎提交入口大全
  • 网站建设公司哪里找广告投放推广平台
  • 蛋糕店的网站建设咋写拉新推广怎么找渠道
  • 网站建设规划书3000字目前最流行的拓客方法
  • 网站的互动功能七台河网站seo
  • 深圳有哪几个区seo推广软件
  • 如何开发软件程序哈尔滨网络seo公司
  • 企业品牌推广策略郑州seo关键词排名优化