<n-date-picker type="date" style="width: 100%" :formatted-value="formatDate(cylinderModal.dateRegularInspection)" value-format="yyyy-MM-dd" @update:formatted-value="updateDate('dateRegularInspection', $event)" /> function formatDate(date:any) { if (!date) return null; // 如果日期为空,返回空字符串 return date.split('T')[0]; // 将日期字符串以T为分隔符拆分,取第一部分即可 }; function updateDate(field: keyof typeof cylinderModal.value, value:string) { cylinderModal.value[field] = value; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter