vue3 + naive ui card header 和 title 冲突 bug

背景描述

最近发现一个 naive ui 上的问题,之前好好的,某一次升级后就出现了一个 bug,Modal 使用 card 布局后,Header Solt 下面的内容不见了,变成了 title,因为这个 solt 里面是有操作 action 的,现在变成了 title 的文字覆盖了这块内容,在本地复现后,发现 naive-ui 高版本存在这个问题,因为 package.json 里面并没有锁定naive-ui 版本,所以每次升级发布后,npm 可能就会安装当前最新的版本。

问题排查

知道了是那个部件那个属性的问题就好办了,知道上官网 github issue 一搜,果然已经有人反馈了:

card卡片 属性title与header Slot同时使用header无法显示 · Issue #5987 · tusen-ai/naive-ui · GitHub

但官网还没有修复这个 issue,所以临时办法就先把之前加的 title 属性移除掉即可。

修复 TSX 代码
复制代码
                <NModal class="bg-gray-400 text-black min-h-screen"
                        headerStyle={{height:"60px"}}
                        footerStyle={{height:"60px"}}
                        preset={"card"}  theme-overrides={{peers: {Card: {titleTextColor: "black"}}}}
                        // show={this.$props.show}  onClose={this.hideModal} title={"演示例子"}  >
                  //去掉这个 title 字段即可   
                  show={this.$props.show}  onClose={this.hideModal}  > 

                    {{
                        default: () => (
                            <div class="h-[800px] overflow-auto ">
                                <div class=" bg-green-100 whitespace-pre-wrap  overflow-auto"
                                     v-html={this.beforeData}></div>
                                <div class=" bg-orange-200" v-html={decodeURIComponent(this.$props.row.message)}>
                                </div>
                                <div class=" bg-blue-100 whitespace-pre-wrap  overflow-auto"
                                     v-html={this.afterData}></div>
                            </div>
                        ),
                        'header': () => (
                            <NSpace>
                                <div>
                                    <NInputNumber v-model:value={this.beforeLimit} placeholder="上翻值" class="w-[120px]" min={10} max={300} />
                                </div>
                                <NButton onClick={()=>this.handleContextQueryClick(true)} type={"info"}>上翻检索</NButton>
                            </NSpace>
                        ),
                        'footer': () => (
                            <NSpace>
                                <div>
                                    <NInputNumber v-model:value={this.afterLimit} placeholder="下翻值" class="w-[120px]" min={10} max={300} />
                                </div>
                                <NButton onClick={()=>this.handleContextQueryClick(false)} type={"primary"}>下翻检索</NButton>
                            </NSpace>
                        )
                    }}
                </NModal>
相关推荐
寂寞的船7 小时前
【Unity Bug挑战】第12期 Awaitable 二次 await 死锁之谜 —— 为什么同一个异步操作等两次就卡死?
unity·c#·游戏引擎·bug
Oll Correct9 小时前
Adobe illustrator 案例十四:花元素标志草图绘制
笔记·ui·adobe·illustrator
北城笑笑2 天前
Vue 109 ,从零搭建 Vue3 + Electron 工程:生态、安全桥接与打包选型( Vue + Electron )
前端·javascript·vue.js·安全·electron·vue
海拥✘2 天前
让 AI 修 AI 平台自己的 Bug:我用 SoduWork 给 SoduWork 提了一个 PR
人工智能·bug
huaqianzkh2 天前
WinForm C#:循环修改控件UI闪烁卡顿?SuspendLayout / ResumeLayout 与 BeginUpdate 优化
开发语言·ui·c#
Oll Correct3 天前
Adobe illustrator 案例十三:adidas标志草图绘制
笔记·ui·adobe·illustrator
FungLeo3 天前
成为全栈·Vue 管理后台篇·Vue3 + Vite + Naive UI:后台工程基座怎么搭
前端·vue.js·ui·typescript·vite·前端工程化·biome
敲上瘾4 天前
Qt Widgets入门:项目模板解析与Hello World
开发语言·数据库·c++·qt·ui·qt6.3
上海懒图科技4 天前
工厂厂区电子地图定位导航:厂区人车精准定位,安全合规双保障
前端·arcgis·vue
Risehuxyc4 天前
fix bug
bug