Delegate independent tasks to specialized agents working concurrently with isolated context.
长列表虚拟滚动优化方案
处理超过 1000 条数据的大型列表渲染时的性能优化方案,包含定高和不定高两种策略。
SKILL.md
Full skill instructions
长列表虚拟滚动优化方案
当列表数据量巨大(如日志列表、审计记录,n > 1000)时,直接渲染会导致 DOM 节点过多,页面卡顿。
核心原理
只渲染当前可视区域 (Viewport) 内的元素,加上缓冲区 (Buffer) 的元素。随着滚动条滚动,动态替换 DOM 内容。
推荐方案
1. 定高列表 (Item Height Fixed)
如果每一行高度固定(例如 40px),推荐使用轻量实现。
使用方式:
<VirtualList :items="logList" :item-height="40" :container-height="400">
<template #default="{ item }">
<div class="log-item">{{ item.message }}</div>
</template>
</VirtualList>
📦 获取完整组件实现:
skill://virtual-list/assets/VirtualList.vue
2. 不定高列表 (Dynamic Height)
如果列表项高度不固定(如包含展开/收起、不同长度文本),计算逻辑会变得复杂。
推荐库: vue-virtual-scroller 的 DynamicScroller 组件。
<template>
<DynamicScroller
:items="items"
:min-item-size="54"
class="scroller"
>
<template #default="{ item, index, active }">
<DynamicScrollerItem
:item="item"
:active="active"
:size-dependencies="[
item.message,
]"
:data-index="index"
>
<div class="message">{{ item.message }}</div>
</DynamicScrollerItem>
</template>
</DynamicScroller>
</template>
注意事项
- 滚动白屏: 滚动过快时可能出现瞬间白屏,适当增加
buffer缓冲区大小。 - 搜索/筛选: 虚拟列表与搜索过滤不冲突,只需对
props.items进行 computed 过滤即可。
📦 可用资源
skill://virtual-list/assets/VirtualList.vue
根据 SKILL.md 中的 IF-THEN 规则判断是否需要加载
More Other skills
brand-guidelines
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with colors/fonts that you can apply to any artifact that has been creating, or can generate a new theme on-the-fly.
internal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill whenever asked to write some sort of internal communications (status reports, leadership updates, 3P updates, company newsletters, FAQs, incident reports, project updates, etc.).
Fundamental design principles for writing maintainable, testable Python code.
responsive-design
Modern responsive layouts using container queries, fluid typography, CSS Grid, and mobile-first strategies.
Generate Playwright tests from scenarios using interactive browser exploration and validation.
Automated website exploration and test case generation using Playwright.
Modern React state management with Redux Toolkit, Zustand, Jotai, and React Query for every state category.
gdpr-data-handling
GDPR-compliant data handling with consent management, data subject rights, and privacy controls.
Python error handling patterns including input validation, exception hierarchies, and partial failure handling. Use when implementing validation logic, designing exception strategies, handling batch processing failures, or building robust APIs.
refactor-plan
Detailed multi-file refactor planning with safety checks and rollback guidance.
