当前位置: 首页 > news >正文

封装日历uniapp,只显示年月不显示日

默认展示最新日期
在这里插入图片描述

子组件

<template><view class="date-picker"><picker mode="date" fields="month" @change="onDateChange" :value="selectedDate"><view class="picker">{{ selectedDate }}<u-icon name="arrow-down-fill" size="12"></u-icon></view></picker></view>
</template><script>export default {data() {return {selectedDate: ''};},created() {const now = new Date();const year = now.getFullYear();const month = (now.getMonth() + 1).toString().padStart(2, '0');this.selectedDate = `${year}-${month}`;},methods: {onDateChange(event) {console.log('11111111111');this.selectedDate = event.detail.value;this.$emit('updateDate', this.selectedDate);}}};
</script><style lang="scss">.date-picker {display: flex;justify-content: center;align-items: center;font-size: 26rpx;width: 200rpx;height: 64rpx;line-height: 64rpx;}.picker {display: flex;}/deep/.u-icon__icon.data-v-172979f2 {margin-left: 8rpx !important;}
</style>

父组件

<script>
import YearMonthPicker from '@/components/YearMonthPicker.vue'; // 修改路径为实际路径export default {components: {YearMonthPicker},data() {return {selectedDate: ''};},methods: {updateDate(date) {this.selectedDate = date;},}
};
</script>
http://www.lryc.cn/news/393347.html

相关文章:

  • golang线程池ants-实现架构
  • Mysql面试合集
  • Android Gradle 开发与应用 (五): 构建变体与自定义任务
  • Django学习第六天
  • docker部署mycat,连接上面一篇的一主二从mysql
  • VUE2拖拽组件:vue-draggable-resizable-gorkys
  • 容器:stack
  • 跨平台Ribbon UI组件QtitanRibbon全新发布v6.7.0——支持Qt 6.6.3
  • (6) 深入探索Python-Pandas库的核心数据结构:DataFrame全面解析
  • 在 Azure 云中开始使用适用于 Ubuntu 的 Grafana
  • 1.Python学习笔记
  • 中英双语介绍百老汇著名歌剧:《猫》(Cats)和《剧院魅影》(The Phantom of the Opera)
  • RpcChannel的调用过程
  • 东芝TB6560AHQ/AFG步进电机驱动IC:解锁卓越的电机控制性能
  • 免杀笔记 ----> DLL注入
  • 奇迹MU 骷髅战士在哪
  • leetcode力扣_贪心思想
  • Vue中Class数据绑定
  • Python数据分析案例49——基于机器学习的垃圾邮件分类系统构建(朴素贝叶斯,支持向量机)
  • 贪心算法-以学籍管理系统为例
  • PyCharm 安装
  • C++:对象指针访问成员函数
  • Linux 防火墙配置指南:firewalld 端口管理应用案例(二十个实列)
  • 推荐Bulk Image Downloader插件下载网页中图片链接很好用
  • 详解前缀码与前缀编码
  • 数据库管理工具 -- Navicat Premium v17.0.8 特别版
  • 【Linux】进程创建和终止 | slab分配器
  • 计算机网络--网络层
  • 【CSS】如何实现分栏布局
  • 2025湖北武汉智慧教育装备信息化展/智慧校园展/湖北高博会