小编drs*_*ter的帖子

如何在 Storybook 中模拟 Next.js Image 组件?

Next.jsImage在 v10 中引入了一个新组件,它应该是<img>标签的替代品。

尝试查看导入next/imageStorybook 的组件时出现错误:

TypeError: imageData is undefined

我一直在尝试覆盖图像对象preview.js(我使用的一种技术next/router,如此处所述),但我遇到了相同的错误:

// .storybook/preview.js

import Image from 'next/image';

Image = ({ src }) => <img src={src} />;
Run Code Online (Sandbox Code Playgroud)

知道如何覆盖next/imageStorybook 中包的行为吗?

javascript reactjs next.js storybook nextjs-image

5
推荐指数
1
解决办法
2441
查看次数

标签 统计

javascript ×1

next.js ×1

nextjs-image ×1

reactjs ×1

storybook ×1