tusen-ai / naive-ui

A Vue 3 Component Library. Fairly Complete. Theme Customizable. Uses TypeScript. Fast.
https://www.naiveui.com
MIT License
15.53k stars 1.63k forks source link

Nuxt+ Responsive grid [Vue warn]: Hydration style mismatch on #6039

Open hb0730 opened 2 weeks ago

hb0730 commented 2 weeks ago

描述错误

在最新的nuxt中使用 Responsive grid存在一下问题

entry.js:55 [Vue warn]: Hydration style mismatch on 

  - rendered on server: style="display:;grid-column:span NaN / span NaN;margin-left:;"
  - expected on client: style="display:;grid-column:span 1 / span 1;margin-left:;"
  Note: this mismatch is check-only. The DOM will not be rectified in production due to performance overhead.
  You should fix the source of the mismatch. 
  at <GridItem privateSpan=1 privateOffset=0 > 
  at <Grid cols="md:1 lg:4" x-gap=12 y-gap=12  ... > 
  at <ConfigProvider breakpoints= 
{xs: 320, sm: 640, md: 768, lg: 1024, xl: 1280, …}
 > 
  at <App key=3 > 
  at <NuxtRoot>

复现步骤

在最新复现中打开浏览器控制台即可复现

image

最小复现链接

https://codesandbox.io/p/devbox/nuxt-naiveui-grid-fytfhg

系统信息

System:
    OS: macOS 14.2.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 135.59 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.16.1 - ~/Applications/.nvm/versions/node/v18.16.1/bin/node
    Yarn: 1.22.22 - ~/Applications/.nvm/versions/node/v18.16.1/bin/yarn
    npm: 9.5.1 - ~/Applications/.nvm/versions/node/v18.16.1/bin/npm
    pnpm: 8.10.2 - ~/Library/pnpm/pnpm
  Browsers:
    Chrome: 125.0.6422.142
    Safari: 17.2.1
  npmPackages:
    naive-ui: ^2.34.3 => 2.38.2 
    vue: ^3.4.27 => 3.4.27

使用的包管理器

pnpm

验证

jahnli commented 2 weeks ago

https://www.naiveui.com/zh-CN/os-theme/docs/ssr#%E6%B3%A8%E6%84%8F https://www.naiveui.com/zh-CN/os-theme/docs/nuxtjs

看看是否可以解决

hb0730 commented 2 weeks ago

好像是ssr导致的问题,如果使用<ClientOnly>好像没问题,但是所有的@css-render/*css-render都是0.15.14