12451 b553c4e519 feat: API 统一 + 设备详情补全 + H5 导航优化
- API 路由统一: 移除 /api/h5/,统一 /api/pms/ 入口
- 二进制改名: api-server -> pms-api(与服务名一致)
- nginx: 合并 /api/ + /pms/api/ 为 /api/pms/
- 新增 docs/API.md 接口文档
- 后端: CabinetDetail 增加 rssi/pow_fail/address/soc 等字段
- Redis 管道批量读取仓体实时数据(SOC/电压/电流/功率)
- DB: 所有 TIMESTAMP 列改为 DATETIME(修复类型不匹配)
- 用户管理: 新增创建时间/修改时间列,状态改用 Switch
- 角色管理/用户管理: 操作按钮改为图标
- PC 设备详情: 基本信息补全 RSSI/ICCID/电源/地址
- PC 卡片: 通道统计改用 Lucide 图标,颜色统一
- PC 二维码: canvas 渲染,含编号文字,支持右键下载
- H5: 按 uni-app 规范修正导航(navigateTo 替代 reLaunch)
- H5: 详情页加返回导航条
- H5: 扫码支持摄像头(jsQR)+ ?id= 参数
- H5: 底部 tabBar 在所有页面常显
- H5: 首页统计改为 6 项(设备/通道/空闲/充电/充满/故障)
- H5: 下拉刷新 / 上拉加载
- 产品首页: 添加业务联系
- 文档: 清理过时文件,补充缺失规范章节
2026-07-04 04:03:02 +08:00

3.2 KiB

title, impact, impactDescription, type, tags
title impact impactDescription type tags
TransitionGroup Children Must Have Unique Keys HIGH Missing or non-unique keys cause broken animations and Vue warnings gotcha
vue3
transition-group
animation
key
v-for
list-animation

TransitionGroup Children Must Have Unique Keys

Impact: HIGH - Unlike regular <Transition>, the <TransitionGroup> component always requires a unique key attribute on every child element. Without keys, Vue cannot track individual items, animations will break, and you'll see console warnings.

This is a fundamental difference from <Transition> which works on single elements. Since <TransitionGroup> animates lists of elements, Vue needs keys to track which items are entering, leaving, or moving.

Task Checklist

  • Ensure every direct child of <TransitionGroup> has a unique key attribute
  • Use stable identifiers (IDs) rather than array indices for keys
  • Do not use the same key for different items at different times
  • When using v-for, always include :key binding

Incorrect - Missing keys:

<template>
  <!-- WRONG: Missing keys causes broken animations -->
  <TransitionGroup name="list" tag="ul">
    <li v-for="item in items">
      {{ item.name }}
    </li>
  </TransitionGroup>
</template>

Incorrect - Using index as key:

<template>
  <!-- PROBLEMATIC: Index keys cause incorrect animations when list changes -->
  <TransitionGroup name="list" tag="ul">
    <li v-for="(item, index) in items" :key="index">
      {{ item.name }}
    </li>
  </TransitionGroup>
</template>

When using index as key:

  • If you remove item at index 2, what was index 3 becomes index 2
  • Vue thinks index 2 changed content rather than being removed
  • Animations fire on wrong elements

Correct - Unique stable keys:

<template>
  <!-- CORRECT: Unique ID keys for proper tracking -->
  <TransitionGroup name="list" tag="ul">
    <li v-for="item in items" :key="item.id">
      {{ item.name }}
    </li>
  </TransitionGroup>
</template>

Correct - Keys on static children:

<template>
  <!-- CORRECT: Even static children need keys in TransitionGroup -->
  <TransitionGroup name="fade" tag="div">
    <span v-if="showA" key="a">Content A</span>
    <span v-if="showB" key="b">Content B</span>
    <span v-if="showC" key="c">Content C</span>
  </TransitionGroup>
</template>

Common Error Messages

Without keys, you'll see warnings like:

[Vue warn]: <TransitionGroup> children must be keyed.

With Draggable Libraries

When using <TransitionGroup> with libraries like vue.draggable.next, key issues can cause errors:

// Error you might see without proper keys
TypeError: domElement is null

Ensure all draggable items have unique keys:

<template>
  <draggable v-model="items" item-key="id">
    <template #item="{ element }">
      <TransitionGroup name="list" tag="div">
        <div :key="element.id">{{ element.name }}</div>
      </TransitionGroup>
    </template>
  </draggable>
</template>

Reference