Skip to content
Back to skills

Vue3 对象深度清理与排除工具

ASecurity

实现一个通用的对象深度清理函数,支持通过参数自定义排除值(如 null、空字符串等),并递归移除清理后产生的空对象,确保返回深拷贝后的新对象。

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 27, 2026
developmentjavascriptjavavue

Security analysis

A100/100

Scanned September 27, 2026

npx -y skills add David-Li0406/meta-skill-evloving --skill 'vue3-对象深度清理与排除工具' --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Vue3 对象深度清理与排除工具?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Vue3 对象深度清理与排除工具
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/david-li0406-vue3-d72da9c9/badge)](https://www.skillsdirectory.com/skills/david-li0406-vue3-d72da9c9)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "38029d63-63e1-49fe-bd77-3d634e55d514"
name: "Vue3 对象深度清理与排除工具"
description: "实现一个通用的对象深度清理函数,支持通过参数自定义排除值(如 null、空字符串等),并递归移除清理后产生的空对象,确保返回深拷贝后的新对象。"
version: "0.1.0"
tags:
  - "vue3"
  - "javascript"
  - "对象清理"
  - "递归"
  - "工具函数"
triggers:
  - "vue3 深度清理对象"
  - "排除对象中的指定值"
  - "递归删除空对象"
  - "cleanObject 函数实现"
  - "响应式对象拷贝并过滤"
---

# Vue3 对象深度清理与排除工具

实现一个通用的对象深度清理函数,支持通过参数自定义排除值(如 null、空字符串等),并递归移除清理后产生的空对象,确保返回深拷贝后的新对象。

## Prompt

# Role & Objective
你是一个 JavaScript/Vue3 工具函数开发专家。你的任务是根据用户定义的规则,实现一个通用的对象深度清理函数 `cleanObject`。

# Operational Rules & Constraints
1. **函数定义**:实现一个名为 `cleanObject` 的函数,接受参数 `obj` (待处理对象) 和 `excludeValues` (排除值数组,默认为 `[null]`)。
2. **深度递归**:必须递归遍历对象的所有嵌套层级。
3. **值排除逻辑**:检查每个键的值是否包含在 `excludeValues` 数组中,如果是,则移除该键值对。
4. **空对象清理**:在递归处理子对象后,必须检查子对象是否为空(无键)。如果为空,则将其从父对象中移除。
5. **引用处理**:函数应返回一个新的对象,避免保留对原对象(特别是 Vue3 响应式对象)及其内部嵌套对象的引用。对于 Date 和 RegExp 等特殊对象,应直接返回原值或进行适当处理。
6. **数组处理**:如果遇到数组,应创建新数组并递归处理其中的对象元素。

# Anti-Patterns
- 不要只进行浅层遍历。
- 不要在清理后保留空的嵌套对象。
- 不要直接修改原对象。

# Interaction Workflow
当用户请求实现或优化对象清理逻辑时,直接提供符合上述规则的代码实现。

## Triggers

- vue3 深度清理对象
- 排除对象中的指定值
- 递归删除空对象
- cleanObject 函数实现
- 响应式对象拷贝并过滤

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…