← Browse

@ecnu-icalk/jsx

B

在JSX/React开发中,当传入值为空时,自动获取当前日期并格式化为YYYY-MM(如2023-04)进行赋值。

skillclaude

Install

agr install @ecnu-icalk/jsx --target claude

Writes 1 file into .claude/skills/, pinned to git-95d0e0b0.

  • .claude/skills/jsx/SKILL.md

Document


id: "7d6d5722-185a-4f22-a878-ff62c3700795" name: "JSX中默认获取并赋值当月日期" description: "在JSX/React开发中,当传入值为空时,自动获取当前日期并格式化为YYYY-MM(如2023-04)进行赋值。" version: "0.1.0" tags:

  • "jsx"
  • "react"
  • "日期处理"
  • "默认值"
  • "前端" triggers:
  • "jsx中怎么默认拿到当月日期"
  • "jsx中判断value是空的给她赋值当前月日期"
  • "react默认日期设置为当月"
  • "js获取当前年月格式yyyy-MM"

JSX中默认获取并赋值当月日期

在JSX/React开发中,当传入值为空时,自动获取当前日期并格式化为YYYY-MM(如2023-04)进行赋值。

Prompt

Role & Objective

扮演前端开发专家,编写JSX/React代码来处理日期的默认值赋值。

Operational Rules & Constraints

  1. 日期格式:必须将当前日期格式化为“YYYY-MM”的形式(例如:2023-04)。
  2. 月份补零:如果月份小于10,必须在前面补0(例如:4月应为04)。
  3. 空值判断:必须包含逻辑判断,检查输入的value是否为空。如果为空,则将格式化后的当前月份日期赋值给该变量。
  4. JSX语法:代码必须符合JSX/React语法规范,确保变量声明不冲突(避免块级作用域变量重复声明错误)。
  5. 实现方式:使用JavaScript原生的Date对象(getFullYear, getMonth)来获取时间。

Anti-Patterns

  • 不要使用外部日期库(如moment.js)除非用户明确要求。
  • 不要忽略月份需要+1(getMonth从0开始)的逻辑。
  • 不要忽略空值检查直接赋值。

Triggers

  • jsx中怎么默认拿到当月日期
  • jsx中判断value是空的给她赋值当前月日期
  • react默认日期设置为当月
  • js获取当前年月格式yyyy-MM

Trustgrade B

  • passBody integrity

    Whether the stored document is plausibly the kind of file the artifact declares, rather than something fetched by mistake.

  • passType matchnot applicable to this artifact type

    Whether the artifact is really the kind of thing its metadata claims it is.

  • passFreshness

    How long since the source repository was last pushed to.

  • passPrompt injection

    Scans the artifact's own text for instructions aimed at your agent rather than at you.

  • warnLicenseno SPDX license detected

    Whether the source repository declares an SPDX license permissive enough to redistribute.

How the grade is calculated

Each check contributes 0 points when it passes, 1 when it warns, and 2 when it fails. The total maps to a letter:

  • Aevery check passed
  • Bone warning
  • Ctwo warnings
  • Dprompt injection or body integrity failed, or three warnings
  • Fone of those failed, and something else is wrong

These are automated hygiene checks, not a security audit, and not a dependency or vulnerability scan. A grade of A means nothing was flagged — not that the artifact is safe.

Versions

  • git-95d0e0b0a5532026-07-31