我想在我正在构建的 Next.js 项目中使用 CSS Houdini。我已经通过 安装yarn
了我想与css-paint-polyfill
. 我在这里遵循 webpack 说明https://houdini.how/usage
这是我的组件:
import 'css-paint-polyfill';
import workletURL from 'url-loader!css-houdini-lines';
import styles from './Separator.module.css';
CSS.paintWorklet.addModule(workletURL);
export default function Separator() {
return <div className={styles.separator} />;
}
我越来越害怕了
error - ReferenceError: window is not defined
at /home/tithos/code/web/new-tim/node_modules/css-paint-polyfill/dist/css-paint-polyfill.js:1:239
我尝试将导入css-paint-polyfill
放在 useEffect 中,但抛出另一个错误。const DynamicComponent = dynamic(() => import('../components/hello'))
我什至从https://nextjs.org/docs/advanced-features/dynamic-import尝试过,但我不知道如何引用该库。
有没有人解决这个问题?