请告诉我是否有其他方法可以使用 v-date-picker 来执行此操作。我只希望用户能够选择年份和月份,然后日期选择器菜单应该关闭。
这是我的 html 作为示例,但我不介意使用不同的代码,只要它仍然使用 v-date-picker。
ts,datePicked 方法有我尝试过但不起作用的方法
export default Vue.extend({
data() {
return {
monthMenu: false,
month: new Date(new Date().getFullYear(), new Date().getMonth()).toISOString()
.substr(0, 10),
};
},
computed: {
txtMonth(): string {
const [year, month, day] = this.month.split('-');
return `${year}/${month}/${day}`;
},
},
methods: {
datePicked(log: any) {
/* eslint-disable */
console.log('here2');
// const el = document.getElementsByClassName('v-date-picker-table--month') as unknown as HTMLElement;
const acc = document.getElementsByClassName('v-date-picker-table--month');
let i;
for (i = 0; i < acc.length; i++) {
acc[i].addEventLis tener("click",function() {
console.log('here');
// this.monthMenu = false
});
}
},
},
});
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号