当前位置:网站首页>uniapp实现出生日期/时间选择效果
uniapp实现出生日期/时间选择效果
2022-04-22 02:14:00 【iii2stay】
uniapp官网关于日期选择器:picker | uni-app官网
van-cell是vant里一个组件
<!-- 出生日期 -->
<picker mode="date" :value="date" :start="startDate" :end="endDate" @change="bindDateChange" v-show="isShow">
<van-cell is-link title="出生日期" mode="date" :value="date" :start="startDate" :end="endDate" />
</picker>
如果不用vant组件 可以这样写
<picker mode="date" :value="date" :start="startDate" :end="endDate" @change="bindDateChange">
<view class="uni-input">{
{date}}</view>
</picker>
<script>
//出生日期
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: getDate({
format: true
}),
startDate: getDate('start'),
endDate: getDate('end'),
};
},
methods: {
//出生日期
bindDateChange: function(e) {
this.date = e.detail.value;
}
},
};
</script>

版权声明
本文为[iii2stay]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_57607714/article/details/124323601
边栏推荐
- What about first-class insurance? Is there a charge? What are the waiting requirements?
- error:there‘s no Qt version assigned to project please assign a Qt installation in qt project settin
- Leetcode 141, circular linked list
- Register login 1
- XSS跨站脚本攻击学习记录
- Introduction to Alibaba's super large-scale Flink cluster operation and maintenance system
- Command line automatic error correction command: fuck
- Mysql-if-then-else statement
- Good news, Jingzhun GPS Beidou timing system helps South Asia electronic management system
- Swoole high performance in memory database use and configuration tutorial
猜你喜欢

What smart contract? Principle analysis of DAPP contract system customization technology

高级android面试答案,Gradle源码全解析

Leetcode2016. Maximum difference between incremental elements
Analysis of advanced interview questions, Alibaba released the "limited edition" Android zero foundation dictionary

Zuo Chengyun - Dachang brushing class - laying bricks

Leetcode 141, circular linked list

Leetcode 1572, sum of diagonal elements of matrix

Analysis and interpretation of the current situation and challenges faced by enterprise operation and maintenance in the digital era

Introduction to Alibaba's super large-scale Flink cluster operation and maintenance system

Unity3d RPG role playing game source code (top and bottom) --- source code analysis ----- 01 ------ protagonist character animation
随机推荐
What methods can be used to generate sort scan operators, query SQL parsing to generate ast, and then transform to generate physical execution plan?
Page 78 digital twin + smart building solutions
The purpose of software testing, why do you do software testing?
Why won't MySQL lose data when the power is suddenly off? (Collection)
Leetcode 733, image rendering
PaddlePaddle basic usage details (four), PaddlePaddle training text classification model
像堆乐高一样解释神经网络的数学过程
NLP模型小总结
102 page master plan for new generation digital transformation and informatization
Shell knowledge: awk
Flutter跳转界面
Page 50 JD cloud · Ruiqing - building an agile engine for enterprise digital transformation business midrange solution
DEJA_VU3D - Cesium功能集 之 012-军事标绘系列六:自定义多边形
Redis cache database uses redis shake for data synchronization
Tensorflow 2. Chapter 5: Data Preprocessing
MySQL -- master slave synchronization
[programming question] simple error record
Page 107 planning and design of enterprise digital transformation
R language generalized linear model GLM: linear least squares, logarithmic transformation, Poisson, binomial logistic regression analysis, ice cream sales time series data and simulation
Analysis and interpretation of the current situation and challenges faced by enterprise operation and maintenance in the digital era