react-vant icon indicating copy to clipboard operation
react-vant copied to clipboard

🐛 [Bug]: React 18 + Next 13 樣式無法載入問題

Open music1353 opened this issue 3 years ago • 4 comments

Which React Vant packages are impacted?

  • [X] react-vant (React Vant core)
  • [ ] react-vant-icons(React Vant Icon)

What version of React Vant are you using?

3.2.7

Reproduce live demo(codesandebox or stackblitz)?

No response

Descripition

開發環境:Next 13 (app dir) 描述:安裝完 react-vant 後,先測試一下引入 Button,但沒有載入樣式,只呈現原始 html 樣式

另外想請問,react-vant 會與 tailwind 及 scss 互相衝突嗎?

music1353 avatar May 28 '23 10:05 music1353

@music1353 可以参照nextjs demo, 对于使用服务器组件的,可能需要声明 'use client';

不会和 tailwind 和 scss 互相冲突,受css规则影响

3lang3 avatar May 29 '23 10:05 3lang3

@3lang3 nextjs demo 是 Next 12 版本,不確定是不是 Next 13 (app dir) 會無法載入樣式,另我也有聲明 'use client'

music1353 avatar May 29 '23 14:05 music1353

在 src/app/layout.tsx 下引入css

import 'react-vant/lib/index.css'

引入rv的页面或者组件需要申明 'use client'

3lang3 avatar Jun 01 '23 11:06 3lang3

我發現把 app dir 換回 src/app 就可以了 謝謝您的回答!

music1353 avatar Jun 02 '23 07:06 music1353