当前位置:网站首页>Uniapp realizes the effect of birth date / time selection
Uniapp realizes the effect of birth date / time selection
2022-04-22 02:17:00 【iii2stay】
uniapp Official website about date selector :picker | uni-app Official website
van-cell yes vant A component in the
<!-- Date of birth -->
<picker mode="date" :value="date" :start="startDate" :end="endDate" @change="bindDateChange" v-show="isShow">
<van-cell is-link title=" Date of birth " mode="date" :value="date" :start="startDate" :end="endDate" />
</picker>
If not vant Components It can be written like this
<picker mode="date" :value="date" :start="startDate" :end="endDate" @change="bindDateChange">
<view class="uni-input">{
{date}}</view>
</picker>
<script>
// Date of birth
function getDate(type) {
const date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDate();
if (type === 'start') {
year = year - 10;
} else if (type === 'end') {
year = year + 10;
}
month = month > 9 ? month : '0' + month;
day = day > 9 ? day : '0' + day;
return `${year}-${month}-${day}`;
}
export default {
data() {
return {
// Date of birth
date: getDate({
format: true
}),
startDate: getDate('start'),
endDate: getDate('end'),
};
},
methods: {
// Date of birth
bindDateChange: function(e) {
this.date = e.detail.value;
}
},
};
</script>

版权声明
本文为[iii2stay]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220214387235.html
边栏推荐
- Tensorflow 2. Chapter 5: Data Preprocessing
- The difference between B tree and B + tree
- Longest common substring
- Method for extracting middle layer output of CNN model
- DEJA_ Vu3d - cesium feature set 013 - military plotting Series 7: regular polygon
- 72 page Internet smart Park solution
- Use of greendao;
- [FAQ] Anaconda prompt reports an error. Solving environment: failed
- uniapp处理强制刷新问题
- Basic operation of MySQL database ------ (basic addition, deletion, query and modification)
猜你喜欢

Page 49 information planning and digital transformation of petroleum and petrochemical industry

【pytorch图像分类】AlexNet网络结构

Raspberry pie 4B 8g installation log (3) - Programming Environment

Leetcode-232 - queue implementation with stack

信息安全概述

【项目】小帽外卖(七)

高级UI都没弄明白凭什么拿高薪,劲爆

Why won't MySQL lose data when the power is suddenly off? (Collection)

Scala installation and environment configuration

【查看已经安装的包和命令是由哪个包提供的】
随机推荐
Leetcode-232 - queue implementation with stack
Advanced C language formula 41: analysis of classical problems of memory operation I
Leetcode 733, image rendering
Longest common substring
机器学习、深度学习知识点
Register login 1
Review of SV knowledge points
Advanced formula 43 of C language: the meaning of function
Golang 中 select 语句死锁问题
Time and current time judgment in MySQL database
Page 49 information planning and digital transformation of petroleum and petrochemical industry
Interview question: use the program to realize the alternating printing of odd and even numbers from 0 to 100 by two threads
Analysis of advanced interview questions, Alibaba released the "limited edition" Android zero foundation dictionary
DEJA_ Vu3d - cesium feature set 013 - military plotting Series 7: regular polygon
unapp封装一个加载动画
Unity3D RPG角色扮演游戏源码(上下)-----源代码分析----01-----主角人物动画
The difference between B tree and B + tree
[programming question] POKER SIZE
[pytorch image classification] alexnet network structure
面试题:用程序实现两个线程交替打印 0~100 的奇偶数