首页 分享 vant时间控件的使用

vant时间控件的使用

来源:花匠小妙招 时间:2024-12-15 11:38

最新推荐文章于 2024-11-12 14:13:18 发布

小曲曲 于 2019-10-23 11:06:45 发布

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

在这里插入图片描述

<template> <div class="shoukuan"> <!-- 头部公共搜索框 --> <tabbar title="添加团队活动"></tabbar> <div class="con"> <van-cell-group> <van-field v-model="name" clearable label="活动名称" placeholder="请选择活动名称" /> <van-field v-model="starttime" clearable label="开始时间" placeholder="请输入开始时间" @focus="start" /> <van-field v-model="endtime" clearable label="结束时间" placeholder="请输入结束时间" @focus="end" /> </van-cell-group> <van-cell-group> <van-field v-model="message" rows="2" autosize label="活动详情" type="textarea" maxlength="50" placeholder="请输入" show-word-limit /> </van-cell-group> </div> <van-button type="primary" size="large" @click="add">确认添加</van-button> <!-- 开始时间控件 --> <van-popup v-model="show" position="bottom"> <van-datetime-picker v-model="currentDate" type="datetime" :min-date="minDate" :max-date="maxDate" @confirm="confirm" @cancel="cancel" :formatter="formatter" /> </van-popup> <!-- 结束时间控件 --> <van-popup v-model="show1" position="bottom"> <van-datetime-picker v-model="currentDate1" type="datetime" :min-date="minDate" :max-date="maxDate" @confirm="confirm1" @cancel="cancel1" :formatter="formatter" /> </van-popup> </div> </template> <script> import tabbar from "../../components/navbar"; export default { data() { return { name: "", //活动名称 message: "", //活动详情 show: false, //开始时间弹窗 show1: false, //结束时间弹窗 minHour: 10, maxHour: 20, minDate: new Date(), maxDate: new Date(2020, 11, 31), currentDate: new Date(), //开始标准时间 currentDate1: new Date(), //结束标准时间 starttime: "", //开始时间 starttime1: "", //开始时间时间戳 endtime: "", //结束时间 endtime1: "" //结束时间时间戳 }; }, components: { tabbar }, mounted() {}, methods: { // 选择开始时间 start() { this.show = true; }, // 选择结束时间 end() { this.show1 = true; }, // 点击确定 confirm() { this.show = false; this.starttime = this.currentDate.getFullYear() + "年" + (Number(this.currentDate.getMonth()) + 1) + "月" + this.currentDate.getDate() + "日 " + this.currentDate.getHours() + ":" + this.currentDate.getMinutes(); this.starttime1 = new Date(this.currentDate).getTime() / 1000; }, // 点击取消 cancel() { this.show = false; }, confirm1() { this.show1 = false; this.endtime = this.currentDate1.getFullYear() + "年" + (Number(this.currentDate1.getMonth()) + 1) + "月" + this.currentDate1.getDate() + "日 " + this.currentDate1.getHours() + ":" + this.currentDate1.getMinutes(); this.endtime1 = new Date(this.currentDate1).getTime() / 1000; }, cancel1() { this.show1 = false; }, // 处理控件显示的时间格式 formatter(type, value) { // 格式化选择器日期 if (type === "year") { return `${value}年`; } else if (type === "month") { return `${value}月`; } else if (type === "day") { return `${value}日`; } else if (type === "hour") { return `${value}时`; } else if (type === "minute") { return `${value}分`; } return value; }, // 点击添加按钮 add() { if ( !this.name.trim() || !this.starttime.trim() || !this.starttime.trim() || !this.message.trim() ) { this.$toast("请输入完整的活动信息"); } else { this.axios .post("/api/agent_team/addTeamActivity", { activity_name: this.name, activity_content: this.message, start_time: this.starttime1, end_time: this.endtime1 }) .then(data => { this.$toast("添加活动成功"); setTimeout(() => { this.$router.go(-1); }, 1000); }); } } } }; </script> <style lang="less" scoped> .shoukuan { padding-top: 44px; .van-button--large { width: 92%; margin-left: 4%; margin-top: 25%; } } </style>

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176

相关知识

LabVIEW界面设计之控件美化
[VC++]为自定义控件添加ToolTip
一个用MFC的DC实现画图的工具带各种控件资源
STM32之littlevGL系列教程:图片控件(lv
Winform(C#) 国内开源美化控件主题库2:花木兰控件库
好工具推荐系列:分享一个使用NSIS制作安装包的UI插件
在HTML5中,控件元素的 validity 属性返回什么值?
慕尚花坊小程序开发
设计师常用的7款界面设计工具!
灯盏花chi的克隆及其生物信息学分析

网址: vant时间控件的使用 https://www.huajiangbk.com/newsview1108643.html

所属分类:花卉
上一篇: python利用LSTM进行时间
下一篇: input时间表单默认样式修改(

推荐分享