(containerId: string, lineCount: number = 3)
| 101 | * 数据还没加载完时显示灰色条纹动画,告诉用户"正在加载中" |
| 102 | */ |
| 103 | export function showSkeleton(containerId: string, lineCount: number = 3): void { |
| 104 | const el = document.getElementById(containerId); |
| 105 | if (!el) return; |
| 106 | |
| 107 | el.innerHTML = ''; |
| 108 | for (let i = 0; i < lineCount; i++) { |
| 109 | const line = document.createElement('div'); |
| 110 | // 最后一行短一点,看起来更自然 |
| 111 | line.className = 'skeleton skeleton-line' + (i === lineCount - 1 ? ' short' : ''); |
| 112 | el.appendChild(line); |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * 隐藏骨架屏 |
no outgoing calls
no test coverage detected