NCollapseTransition 内内容在首次渲染后被冻结:空数据挂载 → 异步填充后不更新(2.45.0+ 回归)
Author: McPorkChopCreated Aug 28, 2026Updated Sep 13, 2026
Labelsuntriaged
Describe the bug
自 naive-ui 2.45.0 起,NCollapseTransition 的默认插槽只在首次挂载时被调用一次。如果折叠内容读取了挂载之后才变化的响应式数据(例如异步请求填充 NDataTable),内容会被永久冻结——即使父组件已重新渲染并把新数据传进来,表格依旧保持空白(No Data)。
这是 2.45.0 更换 JSX 构建管线(包内新增 es/vue-jsx-vapor/ vdom 层)引入的回归:编译后的 CollapseTransition 把内部插槽标记为 STABLE(_: 1),且 vnode 只带 patchFlag=8 / dynamicProps=["appear"],导致 Vue 的 shouldUpdateComponent 在父组件重渲染时跳过整棵子树,首次挂载时的插槽结果被永久保留。
- 影响版本:2.45.0 / 2.45.1 / 2.45.2(三者的
es/构建字节级相同,全系列受影响) - 正常版本:2.44.1 及更早
- 触发写法:渲染函数 / JSX(纯 SFC
<template>写法不触发,原因见文末)
Steps to reproduce
- 用渲染函数 / JSX 编写组件(
defineComponent+render()),预先创建一个绑定响应式数据的 vnode(如NDataTable),再把它作为插槽内容传入NCollapseTransition。 - 初始数据为空(
shallowRef()/ 空数组),挂载后通过setTimeout(或异步接口)晚赋值填充数据。 - 观察:约 500ms 后
NDataTable应显示 8 行——在 2.45.x 下实际保持空白。
Link to minimal reproduction
System Info
System:
OS: macOS 26.6.2
CPU: (10) arm64 Apple M4
Memory: 668.27 MB / 24.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.22.3 - /Users/admin/.nvm/versions/node/v22.22.3/bin/node
Yarn: 4.9.2 - /Users/admin/.nvm/versions/node/v22.22.3/bin/yarn
npm: 10.9.8 - /Users/admin/.nvm/versions/node/v22.22.3/bin/npm
pnpm: 11.4.0 - /Users/admin/.nvm/versions/node/v22.22.3/bin/pnpm
Browsers:
Chrome: 151.0.7922.175
Edge: 151.0.4129.107
Safari: 26.6.2
npmPackages:
naive-ui: ^2.45.2 => 2.45.2
vue: ^3.5.41 => 3.5.41Used Package Manager
pnpm
Validations
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion.
- The provided reproduction is a minimal reproducible example of the bug.
Source: tusen-ai/naive-ui