在node_modules=>vant=>es=>datetime-picker文件夹index.js中
找到 三处 year-month 在分别在下面添加
//1.
if (this.type === 'year') result.splice(1, 4);
//2.
if (this.type === 'year') {
month = 1
date = 1;
}
//3.
if (this.type === 'year') {
values = values.slice(0, 1);
}
使用
<van-datetime-picker
v-model="currentDate"
type="year"
/>