2
0
Эх сурвалжийг харах

📝 docs(ui-style): add date object usage specification

- add date object standard: always use dayjs object instead of native Date object to avoid "isValid is not a function" error
- provide code examples for both incorrect and correct usage of date objects in form setting
yourname 4 сар өмнө
parent
commit
62db1df153

+ 12 - 0
.roo/rules/13-ui-style.md

@@ -53,6 +53,18 @@
 - 日期选择器添加清除按钮:`allowClear`
 - 日期选择器添加占位提示:`placeholder="请选择日期"`
 - 日期选择器禁用未来日期:`disabledDate={(current) => current && current > dayjs().endOf('day')}`(根据业务需求调整)
+- 日期对象规范:始终使用dayjs对象而非原生Date对象,避免出现"isValid is not a function"错误
+  ```typescript
+  // 错误示例 - 使用原生Date对象
+  form.setFieldsValue({
+    noteDate: new Date(record.noteDate) // 导致验证失败
+  });
+  
+  // 正确示例 - 使用dayjs对象
+  form.setFieldsValue({
+    noteDate: dayjs(record.noteDate) // 正常支持验证方法
+  });
+  ```
 - 日期时间转换规范:
   ```typescript
   // 日期对象转字符串(提交给后端)