(JSX attribute) layout: string
No overload matches this call.
在项目中添加Next,导入next/image
并尝试使用布局道具,如下所示:
<Background src='/img/header.png' quality={100} layout='fill' />
编辑认可的工作道具。
{
"dependencies": {
"next": "10.0.2-canary.4"
}
}
该道具正在运行,但编辑器无法识别。
您的示例说的是Background
而不是Image
。 也许您使用了错误的组件。
我确认layout="fill"
可以在TS上正常使用,甚至可以提供建议。
确保使用import Image from 'next/image'
导入正确的组件。
@styfle现在,我相信我发现了真正的问题,当我将Image Component与样式组件一起使用时,布局道具没有显示出来,为什么?
它可以与标准的import Image from 'next/image'
用法一起使用吗?
如果是这样,那么听起来像是styled-components
。
它与默认导入配合使用,可以解决问题,谢谢!
最有用的评论
它可以与标准的
import Image from 'next/image'
用法一起使用吗?如果是这样,那么听起来像是
styled-components
。