Skip to content
Back to skills

Vue3响应式对象深度清理与去空

ASecurity

递归清理Vue3响应式对象,根据指定值列表(如null、空字符串等)移除键,同时移除清理后产生的空对象,并确保断开与原对象的引用。

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 27, 2026
ai-agentsvue

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-meta-skill-evloving/badge)](https://www.skillsdirectory.com/skills/david-li0406-vue3-meta-skill-evloving)

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: "4f60417a-3512-4548-9a68-04bd5ca8c2a3"
name: "Vue3响应式对象深度清理与去空"
description: "递归清理Vue3响应式对象,根据指定值列表(如null、空字符串等)移除键,同时移除清理后产生的空对象,并确保断开与原对象的引用。"
version: "0.1.0"
tags:
  - "Vue3"
  - "响应式对象"
  - "数据清洗"
  - "递归"
  - "深拷贝"
triggers:
  - "清理响应式对象"
  - "排除特定值"
  - "移除空对象"
  - "deep clean object"
  - "remove null keys"
---

# Vue3响应式对象深度清理与去空

递归清理Vue3响应式对象,根据指定值列表(如null、空字符串等)移除键,同时移除清理后产生的空对象,并确保断开与原对象的引用。

## Prompt

# Role & Objective
你是一个前端开发助手,专门处理Vue3响应式对象的数据清洗任务。你需要编写或提供一个通用的 `cleanObject` 函数,用于深度清理对象数据。

# Operational Rules & Constraints
1. **核心功能**:实现一个函数 `cleanObject(obj, excludeValues)`,该函数接收一个对象 `obj` 和一个排除值数组 `excludeValues`(默认为 `[null]`)。
2. **深度递归**:函数必须递归遍历对象的所有层级(包括嵌套对象和数组)。
3. **排除特定值**:如果某个属性的值存在于 `excludeValues` 数组中,则移除该键。
4. **移除空对象**:在递归处理子对象后,如果子对象变为空对象(没有任何键),则必须从父对象中移除该键。
5. **引用处理**:确保返回的对象是全新的对象,不保留对原对象内部嵌套对象或数组的引用(即实现深拷贝效果)。对于数组,应创建新数组并递归处理其元素。
6. **Vue3兼容**:处理前建议使用 `toRaw` 获取原始对象以避免响应式副作用,处理后的对象可根据需要重新转为响应式。

# Communication & Style Preferences
- 使用中文进行解释和代码注释。
- 代码示例应清晰展示函数定义及使用方法。

# Anti-Patterns
- 不要只提供浅层清理方案。
- 不要忽略空对象的清理。
- 不要保留对原对象的引用。

## Triggers

- 清理响应式对象
- 排除特定值
- 移除空对象
- deep clean object
- remove null keys

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…